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