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

#l = sorted([int(input()) for i in range(N)],reverse=True)

def three(h,w):

    ans = h*w

    for i in range(1,h):

        A = w*i

        B = w*((h-i)//2)

        C = w*((h-i+1)//2)

        ans = min(ans,max(A,B,C)-min(A,B,C))

    return ans

def onetwo(h,w):

    ans = h*w

    for i in range(1,h):

        A = w*i

        B = (h-i)*(w//2)

        C = (h-i)*((w+1)//2)

        ans = min(ans,max(A,B,C)-min(A,B,C))

    return ans

print((min(three(H,W),three(W,H),onetwo(H,W),onetwo(W,H))))
H,W = list(map(int,input().split()))

#l = sorted([int(input()) for i in range(N)],reverse=True)

def three(h,w):

    ans = h*w

    for i in range(h//3,h//3+2):

        A = w*i

        B = w*((h-i)//2)

        C = w*((h-i+1)//2)

        ans = min(ans,max(A,B,C)-min(A,B,C))

    return ans

def onetwo(h,w):

    ans = h*w

    for i in range(h//3,h//3+2):

        A = w*i

        B = (h-i)*(w//2)

        C = (h-i)*((w+1)//2)

        ans = min(ans,max(A,B,C)-min(A,B,C))

    return ans

print((min(three(H,W),three(W,H),onetwo(H,W),onetwo(W,H))))
H, W = list(map(int, input().split()))
# l = sorted([int(input()) for i in range(N)],reverse=True)
def three(h, w):
    ans = h * w
    for i in range(1, h):
        A = w * i
        B = w * ((h - i) // 2)
        C = w * ((h - i + 1) // 2)
        ans = min(ans, max(A, B, C) - min(A, B, C))
    return ans


def onetwo(h, w):
    ans = h * w
    for i in range(1, h):
        A = w * i
        B = (h - i) * (w // 2)
        C = (h - i) * ((w + 1) // 2)
        ans = min(ans, max(A, B, C) - min(A, B, C))
    return ans


print((min(three(H, W), three(W, H), onetwo(H, W), onetwo(W, H))))

H, W = list(map(int, input().split()))
# l = sorted([int(input()) for i in range(N)],reverse=True)
def three(h, w):
    ans = h * w
    for i in range(h // 3, h // 3 + 2):
        A = w * i
        B = w * ((h - i) // 2)
        C = w * ((h - i + 1) // 2)
        ans = min(ans, max(A, B, C) - min(A, B, C))
    return ans


def onetwo(h, w):
    ans = h * w
    for i in range(h // 3, h // 3 + 2):
        A = w * i
        B = (h - i) * (w // 2)
        C = (h - i) * ((w + 1) // 2)
        ans = min(ans, max(A, B, C) - min(A, B, C))
    return ans


print((min(three(H, W), three(W, H), onetwo(H, W), onetwo(W, H))))

-    for i in range(1, h): +    for i in range(h // 3, h // 3 + 2): -    for i in range(1, h): +    for i in range(h // 3, h // 3 + 2):