l,r,m=map(int,input().split()) t=r//m-max((l-1)//m,0) if t > 0:tt = 1 else:tt = 0 print(min((r-l+1)-(r//m-max((l-1)//m,0))+tt,m))