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