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