import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



H, W = lr()

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

    answer = 0

else:

    answer = min(H, W)

# さらに小さくするには縦と横で割る

h = H // 3

area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]

answer = min(answer, max(area)-min(area))

h += 1

area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]

answer = min(answer, max(area)-min(area))

w = W // 3

area = [w * H, (W-w) * (H//2), (W-w) * ((H+1)//2)]

answer = min(answer, max(area)-min(area))

w += 1

area = [w * H, (W-w) * (H//2), (W-w) * ((H+1)//2)]

answer = min(answer, max(area)-min(area))

print(answer)



# 13
import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



H, W = lr()

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

    answer = 0

else:

    answer = min(H, W)

# さらに小さくするには縦と横で割る

def cal(H, W):

    global answer

    h = H // 3

    area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]

    answer = min(answer, max(area)-min(area))

    h += 1

    area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]

    answer = min(answer, max(area)-min(area))



cal(H, W)

cal(W, H)

print(answer)

# 13
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
H, W = lr()
if H % 3 == 0 or W % 3 == 0:
    answer = 0
else:
    answer = min(H, W)
# さらに小さくするには縦と横で割る
h = H // 3
area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)]
answer = min(answer, max(area) - min(area))
h += 1
area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)]
answer = min(answer, max(area) - min(area))
w = W // 3
area = [w * H, (W - w) * (H // 2), (W - w) * ((H + 1) // 2)]
answer = min(answer, max(area) - min(area))
w += 1
area = [w * H, (W - w) * (H // 2), (W - w) * ((H + 1) // 2)]
answer = min(answer, max(area) - min(area))
print(answer)
# 13

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
H, W = lr()
if H % 3 == 0 or W % 3 == 0:
    answer = 0
else:
    answer = min(H, W)
# さらに小さくするには縦と横で割る
def cal(H, W):
    global answer
    h = H // 3
    area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)]
    answer = min(answer, max(area) - min(area))
    h += 1
    area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)]
    answer = min(answer, max(area) - min(area))


cal(H, W)
cal(W, H)
print(answer)
# 13

-h = H // 3 -area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)] -answer = min(answer, max(area) - min(area)) -h += 1 -area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)] -answer = min(answer, max(area) - min(area)) -w = W // 3 -area = [w * H, (W - w) * (H // 2), (W - w) * ((H + 1) // 2)] -answer = min(answer, max(area) - min(area)) -w += 1 -area = [w * H, (W - w) * (H // 2), (W - w) * ((H + 1) // 2)] -answer = min(answer, max(area) - min(area)) +def cal(H, W): +    global answer +    h = H // 3 +    area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)] +    answer = min(answer, max(area) - min(area)) +    h += 1 +    area = [h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)] +    answer = min(answer, max(area) - min(area)) + + +cal(H, W) +cal(W, H)