a = [int(x) for x in input().split()] ans = 0 for v in a: if v % 3 == 0 and v % 5 == 0: ans += 8 elif v % 3 == 0 or v % 5 == 0: ans += 4 else: ans += len(str(v)) print(ans)