import itertools def solve(x): if len(x) <= 0: return 0 else: if x[0] % 3 == 0 and x[0] % 5 == 0: return 8 + solve(x[1:]) elif x[0] % 3 == 0 or x[0] % 5 == 0: return 4 + solve(x[1:]) else: return len(str(x[0])) + solve(x[1:]) x = list(map(int, input().split())) print(solve(x))