L, R, M = map(int,input().split()) list = [] for i in range(L,R+1): list += str(i % M) list = set(list) print(len(list))