H,W = list(map(int, input().split()))



ans = 10**10

for i in range(1, H):

    if (H-i)%2 == 0:

        smax = max(W*i, (H-i)*W//2)

        smin = min(W*i, (H-i)*W//2)

    else:

        smax = max(W*i, (H-i+1)*W//2)

        smin = min(W*i, (H-i-1)*W//2)

    ans = min(ans, smax-smin)

    if W%2 == 1:

        smax = max(W*i, (H-i)*(W+1)//2)

        smin = min(W*i, (H-i)*(W-1)//2)

    else:

        smax = max(W*i, (H-i)*W//2)

        smin = min(W*i, (H-i)*W//2)

    ans = min(ans, smax-smin)



for i in range(1, W):

    if (W-i)%2 == 0:

        smax = max(H*i, (W-i)*H//2)

        smin = min(H*i, (W-i)*H//2)

    else:

        smax = max(H*i, (W-i+1)*H//2)

        smin = min(H*i, (W-i-1)*H//2)

    ans = min(ans, smax-smin)

    if H%2 == 1:

        smax = max(H*i, (W-i)*(H+1)//2)

        smin = min(H*i, (W-i)*(H-1)//2)

    else:

        smax = max(H*i, (W-i)*H//2)

        smin = min(H*i, (W-i)*H//2)

    ans = min(ans, smax-smin)

print(ans)
H,W = list(map(int, input().split()))



ans = []



if H > 2:

    ans.append(W*max(H//3, (H-H//3)//2, H-H//3-(H-H//3)//2)-W*min(H//3, (H-H//3)//2, H-H//3-(H-H//3)//2))

if W > 2:

    ans.append(H*max(W//3, (W-W//3)//2, W-W//3-(W-W//3)//2)-H*min(W//3, (W-W//3)//2, W-W//3-(W-W//3)//2))



num = 10**10

for x in range(1, W):

    num = min(num, max(H*x, (W-x)*(H//2), (W-x)*(H-H//2))-min(H*x, (W-x)*(H//2), (W-x)*(H-H//2)))

ans.append(num)

num = 10**10

for x in range(1, H):

    num = min(num, max(W*x, (H-x)*(W//2), (H-x)*(W-W//2))-min(W*x, (H-x)*(W//2), (H-x)*(W-W//2)))

ans.append(num)

print((min(ans)))
H, W = list(map(int, input().split()))
ans = 10**10
for i in range(1, H):
    if (H - i) % 2 == 0:
        smax = max(W * i, (H - i) * W // 2)
        smin = min(W * i, (H - i) * W // 2)
    else:
        smax = max(W * i, (H - i + 1) * W // 2)
        smin = min(W * i, (H - i - 1) * W // 2)
    ans = min(ans, smax - smin)
    if W % 2 == 1:
        smax = max(W * i, (H - i) * (W + 1) // 2)
        smin = min(W * i, (H - i) * (W - 1) // 2)
    else:
        smax = max(W * i, (H - i) * W // 2)
        smin = min(W * i, (H - i) * W // 2)
    ans = min(ans, smax - smin)
for i in range(1, W):
    if (W - i) % 2 == 0:
        smax = max(H * i, (W - i) * H // 2)
        smin = min(H * i, (W - i) * H // 2)
    else:
        smax = max(H * i, (W - i + 1) * H // 2)
        smin = min(H * i, (W - i - 1) * H // 2)
    ans = min(ans, smax - smin)
    if H % 2 == 1:
        smax = max(H * i, (W - i) * (H + 1) // 2)
        smin = min(H * i, (W - i) * (H - 1) // 2)
    else:
        smax = max(H * i, (W - i) * H // 2)
        smin = min(H * i, (W - i) * H // 2)
    ans = min(ans, smax - smin)
print(ans)

H, W = list(map(int, input().split()))
ans = []
if H > 2:
    ans.append(
        W * max(H // 3, (H - H // 3) // 2, H - H // 3 - (H - H // 3) // 2)
        - W * min(H // 3, (H - H // 3) // 2, H - H // 3 - (H - H // 3) // 2)
    )
if W > 2:
    ans.append(
        H * max(W // 3, (W - W // 3) // 2, W - W // 3 - (W - W // 3) // 2)
        - H * min(W // 3, (W - W // 3) // 2, W - W // 3 - (W - W // 3) // 2)
    )
num = 10**10
for x in range(1, W):
    num = min(
        num,
        max(H * x, (W - x) * (H // 2), (W - x) * (H - H // 2))
        - min(H * x, (W - x) * (H // 2), (W - x) * (H - H // 2)),
    )
ans.append(num)
num = 10**10
for x in range(1, H):
    num = min(
        num,
        max(W * x, (H - x) * (W // 2), (H - x) * (W - W // 2))
        - min(W * x, (H - x) * (W // 2), (H - x) * (W - W // 2)),
    )
ans.append(num)
print((min(ans)))

-ans = 10**10 -for i in range(1, H): -    if (H - i) % 2 == 0: -        smax = max(W * i, (H - i) * W // 2) -        smin = min(W * i, (H - i) * W // 2) -    else: -        smax = max(W * i, (H - i + 1) * W // 2) -        smin = min(W * i, (H - i - 1) * W // 2) -    ans = min(ans, smax - smin) -    if W % 2 == 1: -        smax = max(W * i, (H - i) * (W + 1) // 2) -        smin = min(W * i, (H - i) * (W - 1) // 2) -    else: -        smax = max(W * i, (H - i) * W // 2) -        smin = min(W * i, (H - i) * W // 2) -    ans = min(ans, smax - smin) -for i in range(1, W): -    if (W - i) % 2 == 0: -        smax = max(H * i, (W - i) * H // 2) -        smin = min(H * i, (W - i) * H // 2) -    else: -        smax = max(H * i, (W - i + 1) * H // 2) -        smin = min(H * i, (W - i - 1) * H // 2) -    ans = min(ans, smax - smin) -    if H % 2 == 1: -        smax = max(H * i, (W - i) * (H + 1) // 2) -        smin = min(H * i, (W - i) * (H - 1) // 2) -    else: -        smax = max(H * i, (W - i) * H // 2) -        smin = min(H * i, (W - i) * H // 2) -    ans = min(ans, smax - smin) -print(ans) +ans = [] +if H > 2: +    ans.append( +        W * max(H // 3, (H - H // 3) // 2, H - H // 3 - (H - H // 3) // 2) +        - W * min(H // 3, (H - H // 3) // 2, H - H // 3 - (H - H // 3) // 2) +    ) +if W > 2: +    ans.append( +        H * max(W // 3, (W - W // 3) // 2, W - W // 3 - (W - W // 3) // 2) +        - H * min(W // 3, (W - W // 3) // 2, W - W // 3 - (W - W // 3) // 2) +    ) +num = 10**10 +for x in range(1, W): +    num = min( +        num, +        max(H * x, (W - x) * (H // 2), (W - x) * (H - H // 2)) +        - min(H * x, (W - x) * (H // 2), (W - x) * (H - H // 2)), +    ) +ans.append(num) +num = 10**10 +for x in range(1, H): +    num = min( +        num, +        max(W * x, (H - x) * (W // 2), (H - x) * (W - W // 2)) +        - min(W * x, (H - x) * (W // 2), (H - x) * (W - W // 2)), +    ) +ans.append(num) +print((min(ans)))