import math

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

ans = 10**10

for h in range(1, H):

    A = h * W

    #残りを横に割る

    B = W*math.ceil((H-h)/2)

    C = H*W - A - B

    tmp = max([A,B,C]) - min([A,B,C])

    ans = min(ans, tmp)

    #残りを縦に割る

    B = (H-h)*math.ceil(W/2)

    C = H*W - A - B

    tmp = max([A,B,C]) - min([A,B,C])

    ans = min(ans, tmp)



# 縦横入れ替え

H, W = W, H

for h in range(1, H):

    A = h * W

    #残りを横に割る

    B = W*math.ceil((H-h)/2)

    C = H*W - A - B

    tmp = max([A,B,C]) - min([A,B,C])

    ans = min(ans, tmp)

    #残りを縦に割る

    B = (H-h)*math.ceil(W/2)

    C = H*W - A - B

    tmp = max([A,B,C]) - min([A,B,C])

    ans = min(ans, tmp)

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



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

    print((0))

    exit()





ans = H*W

# 高さを変えて調べる

for h in range(1, H+1):

    a = h*W

    #残りを高さで割る場合

    b = ((H-h)//2) * W

    c = H*W - a - b

    ans = min(ans, max([a,b,c]) - min([a,b,c]))





    #残りを幅で割る場合

    b = (H-h) * (W//2)

    c = H*W - a - b

    ans = min(ans, max([a,b,c]) - min([a,b,c]))







# 幅を変えて調べる

for w in range(1, W+1):

    a = H*w

    #残りを高さで割る場合

    b = (W-w) * (H//2)

    c = H*W - a - b

    ans = min(ans, max([a,b,c]) - min([a,b,c]))





    #残りを幅で割る場合

    b = ((W-w)//2) * H

    c = H*W - a - b

    ans = min(ans, max([a,b,c]) - min([a,b,c]))



print(ans)
import math

H, W = list(map(int, input().split()))
ans = 10**10
for h in range(1, H):
    A = h * W
    # 残りを横に割る
    B = W * math.ceil((H - h) / 2)
    C = H * W - A - B
    tmp = max([A, B, C]) - min([A, B, C])
    ans = min(ans, tmp)
    # 残りを縦に割る
    B = (H - h) * math.ceil(W / 2)
    C = H * W - A - B
    tmp = max([A, B, C]) - min([A, B, C])
    ans = min(ans, tmp)
# 縦横入れ替え
H, W = W, H
for h in range(1, H):
    A = h * W
    # 残りを横に割る
    B = W * math.ceil((H - h) / 2)
    C = H * W - A - B
    tmp = max([A, B, C]) - min([A, B, C])
    ans = min(ans, tmp)
    # 残りを縦に割る
    B = (H - h) * math.ceil(W / 2)
    C = H * W - A - B
    tmp = max([A, B, C]) - min([A, B, C])
    ans = min(ans, tmp)
print(ans)

H, W = list(map(int, input().split()))
if H % 3 == 0 or W % 3 == 0:
    print((0))
    exit()
ans = H * W
# 高さを変えて調べる
for h in range(1, H + 1):
    a = h * W
    # 残りを高さで割る場合
    b = ((H - h) // 2) * W
    c = H * W - a - b
    ans = min(ans, max([a, b, c]) - min([a, b, c]))
    # 残りを幅で割る場合
    b = (H - h) * (W // 2)
    c = H * W - a - b
    ans = min(ans, max([a, b, c]) - min([a, b, c]))
# 幅を変えて調べる
for w in range(1, W + 1):
    a = H * w
    # 残りを高さで割る場合
    b = (W - w) * (H // 2)
    c = H * W - a - b
    ans = min(ans, max([a, b, c]) - min([a, b, c]))
    # 残りを幅で割る場合
    b = ((W - w) // 2) * H
    c = H * W - a - b
    ans = min(ans, max([a, b, c]) - min([a, b, c]))
print(ans)

-import math - -ans = 10**10 -for h in range(1, H): -    A = h * W -    # 残りを横に割る -    B = W * math.ceil((H - h) / 2) -    C = H * W - A - B -    tmp = max([A, B, C]) - min([A, B, C]) -    ans = min(ans, tmp) -    # 残りを縦に割る -    B = (H - h) * math.ceil(W / 2) -    C = H * W - A - B -    tmp = max([A, B, C]) - min([A, B, C]) -    ans = min(ans, tmp) -# 縦横入れ替え -H, W = W, H -for h in range(1, H): -    A = h * W -    # 残りを横に割る -    B = W * math.ceil((H - h) / 2) -    C = H * W - A - B -    tmp = max([A, B, C]) - min([A, B, C]) -    ans = min(ans, tmp) -    # 残りを縦に割る -    B = (H - h) * math.ceil(W / 2) -    C = H * W - A - B -    tmp = max([A, B, C]) - min([A, B, C]) -    ans = min(ans, tmp) +if H % 3 == 0 or W % 3 == 0: +    print((0)) +    exit() +ans = H * W +# 高さを変えて調べる +for h in range(1, H + 1): +    a = h * W +    # 残りを高さで割る場合 +    b = ((H - h) // 2) * W +    c = H * W - a - b +    ans = min(ans, max([a, b, c]) - min([a, b, c])) +    # 残りを幅で割る場合 +    b = (H - h) * (W // 2) +    c = H * W - a - b +    ans = min(ans, max([a, b, c]) - min([a, b, c])) +# 幅を変えて調べる +for w in range(1, W + 1): +    a = H * w +    # 残りを高さで割る場合 +    b = (W - w) * (H // 2) +    c = H * W - a - b +    ans = min(ans, max([a, b, c]) - min([a, b, c])) +    # 残りを幅で割る場合 +    b = ((W - w) // 2) * H +    c = H * W - a - b +    ans = min(ans, max([a, b, c]) - min([a, b, c]))