from math import floor,ceil

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

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

    print((0))

    exit()

ans = min(H,W)

for i in range(1,W):

    M = max(i*H,floor(H/2)*(W-i),ceil(H/2)*(W-i))

    m = min(i*H,floor(H/2)*(W-i),ceil(H/2)*(W-i))

    if M-m<ans:

        ans = M-m

for i in range(1,H):

    M = max(i*W,floor(W/2)*(H-i),ceil(W/2)*(H-i))

    m = min(i*W,floor(W/2)*(H-i),ceil(W/2)*(H-i))

    if M-m<ans:

        ans = M-m

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



def split2(h,w):

    if h%2==0 or w%2==0:

        return h*w//2,h*w//2

    else:

        h,w = max(h,w),min(h,w)

        return h//2*w,(h+1)//2*w



ans = H*W

for i in range(1,H):

    h = H-i

    w = W

    s1 = W*i

    s2,s3 = split2(h,w)

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



for i in range(1,W):

    h = H

    w = W-i

    s1 = H*i

    s2,s3 = split2(h,w)

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



print(ans)
from math import floor, ceil

H, W = list(map(int, input().split()))
if H % 3 == 0 or W % 3 == 0:
    print((0))
    exit()
ans = min(H, W)
for i in range(1, W):
    M = max(i * H, floor(H / 2) * (W - i), ceil(H / 2) * (W - i))
    m = min(i * H, floor(H / 2) * (W - i), ceil(H / 2) * (W - i))
    if M - m < ans:
        ans = M - m
for i in range(1, H):
    M = max(i * W, floor(W / 2) * (H - i), ceil(W / 2) * (H - i))
    m = min(i * W, floor(W / 2) * (H - i), ceil(W / 2) * (H - i))
    if M - m < ans:
        ans = M - m
print(ans)

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


def split2(h, w):
    if h % 2 == 0 or w % 2 == 0:
        return h * w // 2, h * w // 2
    else:
        h, w = max(h, w), min(h, w)
        return h // 2 * w, (h + 1) // 2 * w


ans = H * W
for i in range(1, H):
    h = H - i
    w = W
    s1 = W * i
    s2, s3 = split2(h, w)
    ans = min(max(s1, s2, s3) - min(s1, s2, s3), ans)
for i in range(1, W):
    h = H
    w = W - i
    s1 = H * i
    s2, s3 = split2(h, w)
    ans = min(max(s1, s2, s3) - min(s1, s2, s3), ans)
print(ans)

-from math import floor, ceil +H, W = list(map(int, input().split())) -H, W = list(map(int, input().split())) -if H % 3 == 0 or W % 3 == 0: -    print((0)) -    exit() -ans = min(H, W) + +def split2(h, w): +    if h % 2 == 0 or w % 2 == 0: +        return h * w // 2, h * w // 2 +    else: +        h, w = max(h, w), min(h, w) +        return h // 2 * w, (h + 1) // 2 * w + + +ans = H * W +for i in range(1, H): +    h = H - i +    w = W +    s1 = W * i +    s2, s3 = split2(h, w) +    ans = min(max(s1, s2, s3) - min(s1, s2, s3), ans) -    M = max(i * H, floor(H / 2) * (W - i), ceil(H / 2) * (W - i)) -    m = min(i * H, floor(H / 2) * (W - i), ceil(H / 2) * (W - i)) -    if M - m < ans: -        ans = M - m -for i in range(1, H): -    M = max(i * W, floor(W / 2) * (H - i), ceil(W / 2) * (H - i)) -    m = min(i * W, floor(W / 2) * (H - i), ceil(W / 2) * (H - i)) -    if M - m < ans: -        ans = M - m +    h = H +    w = W - i +    s1 = H * i +    s2, s3 = split2(h, w) +    ans = min(max(s1, s2, s3) - min(s1, s2, s3), ans)