a=list(map(int,input().strip().split(" "))) count=0 for i in range(len(a)): if a[i]%3==0 and a[i]%5==0: count+=8 elif a[i]%3==0: count+=4 elif a[i]%5==0: count+=4 else: count+=len(str(a[i])) print(count)