num = int(input())
numbers = list(map(int, str(num)))
sum = 0
for i in numbers:
if i <= 4:
sum += i
print(sum)
num = int(input())
numbers = list(map(int, str(num)))
sum = 0
for i in numbers:
if i <= 4:
sum += i
print(sum)