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