def solve(h, w):

    res = float('inf')

    for hh in range(h + 1):

        s1 = hh * w

        ww = w // 2

        s2 = (h - hh) * ww

        s3 = (h - hh) * (w - ww)

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

    return res





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



ans = H * W

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

    ans = 0

else:

    ans = min(H, W)



ans = min(ans, solve(H, W))

ans = min(ans, solve(W, H))

print(ans)

def calc(h, w):

    w_1_1 = w // 3

    w_1_2 = w_1_1 + 1



    ans = inf

    for w_1 in w_1_1, w_1_2:

        s_1 = w_1 * h



        # 縦に割る

        w_2 = (w - w_1) // 2

        s_2 = w_2 * h



        w_3 = w - w_1 - w_2

        s_3 = w_3 * h



        ss = [s_1, s_2, s_3]

        # print(h, w, ss)

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



        # 横に割る

        h_2 = h // 2

        s_2 = h_2 * (w - w_1)



        h_3 = h - h_2

        s_3 = h_3 * (w - w_1)



        ss = [s_1, s_2, s_3]

        # print(h, w, ss)

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



    return ans





inf = float('inf')



h, w = list(map(int, input().split()))



a = calc(h, w)

b = calc(w, h)

print((min(a, b)))

def solve(h, w):
    res = float("inf")
    for hh in range(h + 1):
        s1 = hh * w
        ww = w // 2
        s2 = (h - hh) * ww
        s3 = (h - hh) * (w - ww)
        res = min(res, max(s1, s2, s3) - min(s1, s2, s3))
    return res


H, W = list(map(int, input().split()))
ans = H * W
if H % 3 == 0 or W % 3 == 0:
    ans = 0
else:
    ans = min(H, W)
ans = min(ans, solve(H, W))
ans = min(ans, solve(W, H))
print(ans)

def calc(h, w):
    w_1_1 = w // 3
    w_1_2 = w_1_1 + 1
    ans = inf
    for w_1 in w_1_1, w_1_2:
        s_1 = w_1 * h
        # 縦に割る
        w_2 = (w - w_1) // 2
        s_2 = w_2 * h
        w_3 = w - w_1 - w_2
        s_3 = w_3 * h
        ss = [s_1, s_2, s_3]
        # print(h, w, ss)
        ans = min(ans, max(ss) - min(ss))
        # 横に割る
        h_2 = h // 2
        s_2 = h_2 * (w - w_1)
        h_3 = h - h_2
        s_3 = h_3 * (w - w_1)
        ss = [s_1, s_2, s_3]
        # print(h, w, ss)
        ans = min(ans, max(ss) - min(ss))
    return ans


inf = float("inf")
h, w = list(map(int, input().split()))
a = calc(h, w)
b = calc(w, h)
print((min(a, b)))

-def solve(h, w): -    res = float("inf") -    for hh in range(h + 1): -        s1 = hh * w -        ww = w // 2 -        s2 = (h - hh) * ww -        s3 = (h - hh) * (w - ww) -        res = min(res, max(s1, s2, s3) - min(s1, s2, s3)) -    return res +def calc(h, w): +    w_1_1 = w // 3 +    w_1_2 = w_1_1 + 1 +    ans = inf +    for w_1 in w_1_1, w_1_2: +        s_1 = w_1 * h +        # 縦に割る +        w_2 = (w - w_1) // 2 +        s_2 = w_2 * h +        w_3 = w - w_1 - w_2 +        s_3 = w_3 * h +        ss = [s_1, s_2, s_3] +        # print(h, w, ss) +        ans = min(ans, max(ss) - min(ss)) +        # 横に割る +        h_2 = h // 2 +        s_2 = h_2 * (w - w_1) +        h_3 = h - h_2 +        s_3 = h_3 * (w - w_1) +        ss = [s_1, s_2, s_3] +        # print(h, w, ss) +        ans = min(ans, max(ss) - min(ss)) +    return ans -H, W = list(map(int, input().split())) -ans = H * W -if H % 3 == 0 or W % 3 == 0: -    ans = 0 -else: -    ans = min(H, W) -ans = min(ans, solve(H, W)) -ans = min(ans, solve(W, H)) -print(ans) +inf = float("inf") +h, w = list(map(int, input().split())) +a = calc(h, w) +b = calc(w, h) +print((min(a, b)))