from itertools import combinations from functools import reduce print(sum(min(box) + 2 * sum(box) for box in ([int(a) * int(b) for a, b in combinations(l.split('x'), 2)] for l in open('input'))))