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