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