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



def get_ans(A, B):

    ans = A * B

    for A1 in range(1, A):

        A2 = (A - A1) // 2

        A3 = A - A1 - A2

        S = [A1 * B, A2 * B, A3 * B]

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



    for A1 in range(1, A):

        B2 = B // 2

        B3 = B - B2

        S = [A1 * B, (A - A1) * B2, (A - A1) * B3]

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



    return ans



print((min(get_ans(H, W), get_ans(W, H))))

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



def getMinDiff(A, B):

    if A % 3 == 0:

        return 0

    elif B % 2 == 0:

        return B // 2

    else:

        ans = B # 横3段に分ける場合の値



        # T字型に分ける場合

        for i in range(A % 3 + 1):

            A1 = A // 3 + i # 上半分の縦幅

            B1, B2 = B // 2, (B + 1) // 2 # 下半分の左側、右側の横幅

            Ss = [A1 * B, (A - A1) * B1, (A - A1) * B2]

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

        return ans



print((min(getMinDiff(H, W), getMinDiff(W, H))))

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


def get_ans(A, B):
    ans = A * B
    for A1 in range(1, A):
        A2 = (A - A1) // 2
        A3 = A - A1 - A2
        S = [A1 * B, A2 * B, A3 * B]
        ans = min(ans, max(S) - min(S))
    for A1 in range(1, A):
        B2 = B // 2
        B3 = B - B2
        S = [A1 * B, (A - A1) * B2, (A - A1) * B3]
        ans = min(ans, max(S) - min(S))
    return ans


print((min(get_ans(H, W), get_ans(W, H))))

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


def getMinDiff(A, B):
    if A % 3 == 0:
        return 0
    elif B % 2 == 0:
        return B // 2
    else:
        ans = B  # 横3段に分ける場合の値
        # T字型に分ける場合
        for i in range(A % 3 + 1):
            A1 = A // 3 + i  # 上半分の縦幅
            B1, B2 = B // 2, (B + 1) // 2  # 下半分の左側、右側の横幅
            Ss = [A1 * B, (A - A1) * B1, (A - A1) * B2]
            ans = min(ans, max(Ss) - min(Ss))
        return ans


print((min(getMinDiff(H, W), getMinDiff(W, H))))

-def get_ans(A, B): -    ans = A * B -    for A1 in range(1, A): -        A2 = (A - A1) // 2 -        A3 = A - A1 - A2 -        S = [A1 * B, A2 * B, A3 * B] -        ans = min(ans, max(S) - min(S)) -    for A1 in range(1, A): -        B2 = B // 2 -        B3 = B - B2 -        S = [A1 * B, (A - A1) * B2, (A - A1) * B3] -        ans = min(ans, max(S) - min(S)) -    return ans +def getMinDiff(A, B): +    if A % 3 == 0: +        return 0 +    elif B % 2 == 0: +        return B // 2 +    else: +        ans = B  # 横3段に分ける場合の値 +        # T字型に分ける場合 +        for i in range(A % 3 + 1): +            A1 = A // 3 + i  # 上半分の縦幅 +            B1, B2 = B // 2, (B + 1) // 2  # 下半分の左側、右側の横幅 +            Ss = [A1 * B, (A - A1) * B1, (A - A1) * B2] +            ans = min(ans, max(Ss) - min(Ss)) +        return ans -print((min(get_ans(H, W), get_ans(W, H)))) +print((min(getMinDiff(H, W), getMinDiff(W, H))))