n, x = map(int, input().split()) c = 0 for i in range(1,n+1): while i > 0: y = i % 10 i = i // 10 if y == x: c = c + 1 print(c)