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