n, x = map(int, input().split())
count = 0
for number in range(1, n + 1):
temp = number
while temp > 0:
digit = temp % 10
if digit == x:
count += 1
temp //= 10
print(count)

n, x = map(int, input().split())
count = 0
for number in range(1, n + 1):
temp = number
while temp > 0:
digit = temp % 10
if digit == x:
count += 1
temp //= 10
print(count)