A=list(map(int,input().split())) ans=0 for i in A: if i%15==0: ans+=8 elif i%3==0 or i%5==0: ans+=4 else: ans+=len(str(i)) print(ans)