import sys input = sys.stdin.readline A=list(map(int,input().split())) ANS=0 for a in A: if a%3==0 and a%5==0: ANS+=8 elif a%3==0 or a%5==0: ANS+=4 else: ANS+=len(str(a)) print(ANS)