a, b = map(int, input().split()) b, count_a = str(b), 0 for i in range(1, a + 1): i = str(i) if b in i: c = i.count(b) count_a += c print(count_a)