i = int(input())
k = i
count=0
n=9
while i > 0:
if i % 10 < n:
n = i % 10
i = i // 10
while k > 0:
if k mod 10 == n:
count += 1
k = k // 10
print(count)
i = int(input())
k = i
count=0
n=9
while i > 0:
if i % 10 < n:
n = i % 10
i = i // 10
while k > 0:
if k mod 10 == n:
count += 1
k = k // 10
print(count)