def f(n): n=int(n) if n%3==0 and n%5==0: return 8 elif (n%3==0 and n%5) or (n%3 and n%5==0): return 4 else: return len(str(n)) print(sum(map(f,input().split())))