n, m = map(int, input().split())
count = 0
m_str = str(m)
for i in range(1, n + 1):
num_str = str(i)
occurrences = num_str.count(m_str)
if occurrences > 0:
count += occurrences
print(count)
'''
错在没有考虑22,33,44这种数字
n, m = map(int, input().split())
count = 0
c=[]
for i in range(1, n + 1):
if str(m) in str(i): # 把数字转为字符串后检查包含关系
count += 1
c.append(i)
print(count)
print(c)
'''

京公网安备 11010502036488号