# nkj = list(map(int,input().split()))
# values = []
# index = 0
# for i in range(nkj[0],nkj[1]+1):
#     values.append(i)
# total = 0
# ans = []
# for i in values:
#     if (i - int(str(i)[ : : -1])) % (nkj[-1]) == 0:
#         ans.append(i)  
# print(len(ans))



