Need big hint to solve it. I have tried many times but failed.
Your hint is \dfrac {p-a}{d} +1
thanks. I have solved it.