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