def check_three(num): if num % 3 == 0: three = 1 else: three = 0 return three def check_five(num): if num % 5 == 0: five = 1 else: five = 0 return five a = input().split() N = 0 for i in range(len(a)): if check_three(int(a[i])) + check_five(int(a[i])) == 2: N+=8 elif check_three(int(a[i])) + check_five(int(a[i])) == 1: N += 4 else: N += len(a[i]) print(N)