num = [int(i) for i in list(input())]
#1
print(sum(filter(lambda p: p > 5, num)))
#2
print(num.count(0))
#3
print(max(num))
num = [int(i) for i in list(input())]
#1
print(sum(filter(lambda p: p > 5, num)))
#2
print(num.count(0))
#3
print(max(num))