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

if (H*W)%3==0:

    dif = 0

else:

    dif = min(H,W)

    for i in range(1,W//2+1):

        s1 = H*i

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

        s3 = (W-i)*(H-H//2)

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

        dif = min(dif,d)

    for j in range(1,H//2+1):

        s1 = W*j

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

        s3 = (H-j)*(W-W//2)

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

        dif = min(dif,d)

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

cmin = H*W

if H%3==0 or W%3==0:

    ans = 0

else:

    for i in range(H-1):

        s1 = W*(i+1)

        t = H-i-1

        s2 = W*(t//2)

        s3 = W*(t-t//2)

        d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))

        cmin = min(cmin,d)

        t1 = W//2

        s2 = t*t1

        s3 = t*(W-t1)

        d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))

        cmin = min(cmin,d)

    for j in range(W-1):

        s1 = H*(j+1)

        t = W-j-1

        s2 = H*(t//2)

        s3 = H*(t-t//2)

        d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))

        cmin = min(cmin,d)

        t1 = H//2

        s2 = t*t1

        s3 = t*(H-t1)

        d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))

        cmin = min(cmin,d)

    ans = cmin

print(ans)
H, W = list(map(int, input().split()))
if (H * W) % 3 == 0:
    dif = 0
else:
    dif = min(H, W)
    for i in range(1, W // 2 + 1):
        s1 = H * i
        s2 = (W - i) * (H // 2)
        s3 = (W - i) * (H - H // 2)
        d = max(s1, s2, s3) - min(s1, s2, s3)
        dif = min(dif, d)
    for j in range(1, H // 2 + 1):
        s1 = W * j
        s2 = (H - j) * (W // 2)
        s3 = (H - j) * (W - W // 2)
        d = max(s1, s2, s3) - min(s1, s2, s3)
        dif = min(dif, d)
print(dif)

H, W = list(map(int, input().split()))
cmin = H * W
if H % 3 == 0 or W % 3 == 0:
    ans = 0
else:
    for i in range(H - 1):
        s1 = W * (i + 1)
        t = H - i - 1
        s2 = W * (t // 2)
        s3 = W * (t - t // 2)
        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
        cmin = min(cmin, d)
        t1 = W // 2
        s2 = t * t1
        s3 = t * (W - t1)
        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
        cmin = min(cmin, d)
    for j in range(W - 1):
        s1 = H * (j + 1)
        t = W - j - 1
        s2 = H * (t // 2)
        s3 = H * (t - t // 2)
        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
        cmin = min(cmin, d)
        t1 = H // 2
        s2 = t * t1
        s3 = t * (H - t1)
        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
        cmin = min(cmin, d)
    ans = cmin
print(ans)

-if (H * W) % 3 == 0: -    dif = 0 +cmin = H * W +if H % 3 == 0 or W % 3 == 0: +    ans = 0 -    dif = min(H, W) -    for i in range(1, W // 2 + 1): -        s1 = H * i -        s2 = (W - i) * (H // 2) -        s3 = (W - i) * (H - H // 2) -        d = max(s1, s2, s3) - min(s1, s2, s3) -        dif = min(dif, d) -    for j in range(1, H // 2 + 1): -        s1 = W * j -        s2 = (H - j) * (W // 2) -        s3 = (H - j) * (W - W // 2) -        d = max(s1, s2, s3) - min(s1, s2, s3) -        dif = min(dif, d) -print(dif) +    for i in range(H - 1): +        s1 = W * (i + 1) +        t = H - i - 1 +        s2 = W * (t // 2) +        s3 = W * (t - t // 2) +        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1)) +        cmin = min(cmin, d) +        t1 = W // 2 +        s2 = t * t1 +        s3 = t * (W - t1) +        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1)) +        cmin = min(cmin, d) +    for j in range(W - 1): +        s1 = H * (j + 1) +        t = W - j - 1 +        s2 = H * (t // 2) +        s3 = H * (t - t // 2) +        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1)) +        cmin = min(cmin, d) +        t1 = H // 2 +        s2 = t * t1 +        s3 = t * (H - t1) +        d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1)) +        cmin = min(cmin, d) +    ans = cmin +print(ans)