n=map(int,input().split()) cnt=0 for i in n: if i%3==0 and i%5==0: cnt+=8 elif i%3==0 or i%5==0: cnt+=4 else: cnt+=len(str(i)) print(cnt)