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

ans = h*w



if h % 3 == 0 or h % 3 == 0:

    print((0))

    exit()

for i in range(1,w):

    H1, H2= h//2, -(-h//2)

    check = max(h*i,H2*(w-i),H1*(w-i))

    check2 = min(h*i,H1*(w-i),H2*(w-i))

    ans = min(ans,abs(check-check2))

for i in range(1,h):

    w1,w2 = w//2, -(-w//2)

    check = max(w*i,w1*(h-i),w2*(h-i))

    check2 = min(w*i,w1*(h-i),w2*(h-i))

    ans = min(ans,abs(check-check2))

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

ans = float("Inf")

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

    print((0))

    exit()

for i in range(1,h):

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

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

    ans = min(ans,abs(max(i*w,a,b)-min(i*w,a,b)))

for i in range(1,w):

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

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

    ans = min(ans,abs(max(i*h,a,b)-min(i*h,a,b)))

print((min(ans,h,w)))
h, w = list(map(int, input().split()))
ans = h * w
if h % 3 == 0 or h % 3 == 0:
    print((0))
    exit()
for i in range(1, w):
    H1, H2 = h // 2, -(-h // 2)
    check = max(h * i, H2 * (w - i), H1 * (w - i))
    check2 = min(h * i, H1 * (w - i), H2 * (w - i))
    ans = min(ans, abs(check - check2))
for i in range(1, h):
    w1, w2 = w // 2, -(-w // 2)
    check = max(w * i, w1 * (h - i), w2 * (h - i))
    check2 = min(w * i, w1 * (h - i), w2 * (h - i))
    ans = min(ans, abs(check - check2))
print((min(ans, h, w)))

h, w = list(map(int, input().split()))
ans = float("Inf")
if h % 3 == 0 or w % 3 == 0:
    print((0))
    exit()
for i in range(1, h):
    a = (h - i) * (w // 2)
    b = (h - i) * -(-w // 2)
    ans = min(ans, abs(max(i * w, a, b) - min(i * w, a, b)))
for i in range(1, w):
    a = (w - i) * (h // 2)
    b = (w - i) * -(-h // 2)
    ans = min(ans, abs(max(i * h, a, b) - min(i * h, a, b)))
print((min(ans, h, w)))

-ans = h * w -if h % 3 == 0 or h % 3 == 0: +ans = float("Inf") +if h % 3 == 0 or w % 3 == 0: +for i in range(1, h): +    a = (h - i) * (w // 2) +    b = (h - i) * -(-w // 2) +    ans = min(ans, abs(max(i * w, a, b) - min(i * w, a, b))) -    H1, H2 = h // 2, -(-h // 2) -    check = max(h * i, H2 * (w - i), H1 * (w - i)) -    check2 = min(h * i, H1 * (w - i), H2 * (w - i)) -    ans = min(ans, abs(check - check2)) -for i in range(1, h): -    w1, w2 = w // 2, -(-w // 2) -    check = max(w * i, w1 * (h - i), w2 * (h - i)) -    check2 = min(w * i, w1 * (h - i), w2 * (h - i)) -    ans = min(ans, abs(check - check2)) +    a = (w - i) * (h // 2) +    b = (w - i) * -(-h // 2) +    ans = min(ans, abs(max(i * h, a, b) - min(i * h, a, b)))