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