import sys input=lambda: sys.stdin.readline().rstrip() A=[int(i) for i in input().split()] ans=0 for a in A: if a%3==0: ans+=4 if a%5==0: ans+=4 if a%3 and a%5: ans+=len(str(a)) print(ans)