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