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

ans = float('inf')

for h in range(1,H):

    S = [h * W]

    w = W // 2

    S += [(H-h) * w]

    S += [(H-h) * (W-w)]

    ans = min(ans,max(S)-min(S))



for h in range(1,H):

    S = [h * W]

    hb = (H-h) // 2

    S += [hb * W]

    S += [(H-h-hb) * W]

    ans = min(ans,max(S)-min(S))



for w in range(1,W):

    S = [H * w]

    h = H // 2

    S += [h * (W-w)]

    S += [(H-h) * (W-w)]

    ans = min(ans,max(S)-min(S))



for w in range(1,W):

    S = [w * H]

    wb = (W-w) // 2

    S += [wb * H]

    S += [(W-w-wb) * H]

    ans = min(ans,max(S)-min(S))



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

S = H * W

ans = S



for h in range(1,H):

    s1 = h * W

    s2 = W // 2 * (H-h)

    s3 = S-s1-s2

    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))



    s2 = (H-h) // 2 * W

    s3 = S-s1-s2

    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))



for w in range(1,W):

    s1 = H * w

    s2 = H // 2 * (W-w)

    s3 = S-s1-s2

    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))



    s2 = (W-w) // 2 * H

    s3 = S-s1-s2

    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))



print(ans)
H, W = list(map(int, input().split()))
ans = float("inf")
for h in range(1, H):
    S = [h * W]
    w = W // 2
    S += [(H - h) * w]
    S += [(H - h) * (W - w)]
    ans = min(ans, max(S) - min(S))
for h in range(1, H):
    S = [h * W]
    hb = (H - h) // 2
    S += [hb * W]
    S += [(H - h - hb) * W]
    ans = min(ans, max(S) - min(S))
for w in range(1, W):
    S = [H * w]
    h = H // 2
    S += [h * (W - w)]
    S += [(H - h) * (W - w)]
    ans = min(ans, max(S) - min(S))
for w in range(1, W):
    S = [w * H]
    wb = (W - w) // 2
    S += [wb * H]
    S += [(W - w - wb) * H]
    ans = min(ans, max(S) - min(S))
print(ans)

H, W = list(map(int, input().split()))
S = H * W
ans = S
for h in range(1, H):
    s1 = h * W
    s2 = W // 2 * (H - h)
    s3 = S - s1 - s2
    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    s2 = (H - h) // 2 * W
    s3 = S - s1 - s2
    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
for w in range(1, W):
    s1 = H * w
    s2 = H // 2 * (W - w)
    s3 = S - s1 - s2
    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    s2 = (W - w) // 2 * H
    s3 = S - s1 - s2
    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
print(ans)

-ans = float("inf") +S = H * W +ans = S -    S = [h * W] -    w = W // 2 -    S += [(H - h) * w] -    S += [(H - h) * (W - w)] -    ans = min(ans, max(S) - min(S)) -for h in range(1, H): -    S = [h * W] -    hb = (H - h) // 2 -    S += [hb * W] -    S += [(H - h - hb) * W] -    ans = min(ans, max(S) - min(S)) +    s1 = h * W +    s2 = W // 2 * (H - h) +    s3 = S - s1 - s2 +    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3)) +    s2 = (H - h) // 2 * W +    s3 = S - s1 - s2 +    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3)) -    S = [H * w] -    h = H // 2 -    S += [h * (W - w)] -    S += [(H - h) * (W - w)] -    ans = min(ans, max(S) - min(S)) -for w in range(1, W): -    S = [w * H] -    wb = (W - w) // 2 -    S += [wb * H] -    S += [(W - w - wb) * H] -    ans = min(ans, max(S) - min(S)) +    s1 = H * w +    s2 = H // 2 * (W - w) +    s3 = S - s1 - s2 +    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3)) +    s2 = (W - w) // 2 * H +    s3 = S - s1 - s2 +    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))