তালিকার সংখ্যা নির্ণয় - গণিতযজ্ঞ

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.