Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/54a57cdcf7e3755ea687c12508bd83854e033ec3.png" style="max-width: 100.0%;max-height: 100.0%;"/>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.
The first and the single line of the input contains 6 space-separated integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, *a*<sub class="lower-index">3</sub>, *a*<sub class="lower-index">4</sub>, *a*<sub class="lower-index">5</sub> and *a*<sub class="lower-index">6</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.
def solve(a):
    total_sum = 0
    while len(list(filter(lambda x: x > 0, a))) > 3:
        current_sum = 0
        zero_count = 0
        for i in range(6):
            if a[i] == 0:
                zero_count += 1
                continue
            current_sum += a[i] * 2 - 1
        current_sum -= (zero_count * 2)

        b = []
        for i in range(6):
            if a[i] == 0:
                b.append(0)
                continue
            b.append(a[i] - 1)
            if a[i - 1] == 0:
                b[-1] -= 1
            if a[(i + 1) % 6] == 0:
                b[-1] -= 1
        a = b
        total_sum += current_sum

    if sum(1 if e > 0 else 0 for e in a) == 3:
        return total_sum + (sum(a) // 3) ** 2
    return total_sum


# assert solve([2, 4, 5, 3, 3, 6]) == 83
# assert solve([1, 2, 1, 2, 1, 2]) == 13
# assert solve([1, 1, 1, 1, 1, 1]) == 6
# assert solve([45, 19, 48, 18, 46, 21]) == 6099
a = list(map(int, input().split()))

r = solve(a)
print(r)
