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



# =パターン

x, y = divmod(h, 3)

if y == 0:

    x1, x2, x3 = x, x, x

elif y == 1:

    x1, x2, x3 = x+1, x, x

else:

    x1, x2, x3 = x+1, x+1, x



s1, s2, s3 = [x*w for x in (x1, x2, x3)]

ans = s1-s3



# llパターン

x, y = divmod(w, 3)

if y == 0:

    x1, x2, x3 = x, x, x

elif y == 1:

    x1, x2, x3 = x+1, x, x

else:

    x1, x2, x3 = x+1, x+1, x



s1, s2, s3 = [x*h for x in (x1, x2, x3)]

ans = min(ans, s1-s3)



# トパターン

x = -(-w//3)

s1 = x*h

y = w-x

x1, x2 = h//2, (h+1)//2

s2, s3 = x1*y, x2*y

Ss = (s1, s2, s3)

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



# トパターン

x = w//3

s1 = x*h

y = w-x

x1, x2 = h//2, (h+1)//2

s2, s3 = x1*y, x2*y

Ss = (s1, s2, s3)

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



# Tパターン

x = -(-h//3)

s1 = x*w

y = h-x

x1, x2 = w//2, (w+1)//2

s2, s3 = x1*y, x2*y

Ss = (s1, s2, s3)

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



# Tパターン

x = h//3

s1 = x*w

y = h-x

x1, x2 = w//2, (w+1)//2

s2, s3 = x1*y, x2*y

Ss = (s1, s2, s3)

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

print(ans)

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





def solve_ll(a, b):

    x, y = divmod(a, 3)

    X = [x]*3

    for i in range(y):

        X[i] += 1

    s1, s2, s3 = [x*b for x in X]

    return s1-s3





def solve_T(a, b):

    INF = 10**18

    res = INF

    for x in (b//3, -(-b//3)):

        s1 = x*a

        y = b-x

        x1, x2 = a//2, (a+1)//2

        s2, s3 = x1*y, x2*y

        Ss = (s1, s2, s3)

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

    return res





ans = min(solve_T(h, w), solve_T(w, h), solve_ll(h, w), solve_ll(w, h))

print(ans)

h, w = list(map(int, input().split()))
# =パターン
x, y = divmod(h, 3)
if y == 0:
    x1, x2, x3 = x, x, x
elif y == 1:
    x1, x2, x3 = x + 1, x, x
else:
    x1, x2, x3 = x + 1, x + 1, x
s1, s2, s3 = [x * w for x in (x1, x2, x3)]
ans = s1 - s3
# llパターン
x, y = divmod(w, 3)
if y == 0:
    x1, x2, x3 = x, x, x
elif y == 1:
    x1, x2, x3 = x + 1, x, x
else:
    x1, x2, x3 = x + 1, x + 1, x
s1, s2, s3 = [x * h for x in (x1, x2, x3)]
ans = min(ans, s1 - s3)
# トパターン
x = -(-w // 3)
s1 = x * h
y = w - x
x1, x2 = h // 2, (h + 1) // 2
s2, s3 = x1 * y, x2 * y
Ss = (s1, s2, s3)
ans = min(ans, max(Ss) - min(Ss))
# トパターン
x = w // 3
s1 = x * h
y = w - x
x1, x2 = h // 2, (h + 1) // 2
s2, s3 = x1 * y, x2 * y
Ss = (s1, s2, s3)
ans = min(ans, max(Ss) - min(Ss))
# Tパターン
x = -(-h // 3)
s1 = x * w
y = h - x
x1, x2 = w // 2, (w + 1) // 2
s2, s3 = x1 * y, x2 * y
Ss = (s1, s2, s3)
ans = min(ans, max(Ss) - min(Ss))
# Tパターン
x = h // 3
s1 = x * w
y = h - x
x1, x2 = w // 2, (w + 1) // 2
s2, s3 = x1 * y, x2 * y
Ss = (s1, s2, s3)
ans = min(ans, max(Ss) - min(Ss))
print(ans)

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


def solve_ll(a, b):
    x, y = divmod(a, 3)
    X = [x] * 3
    for i in range(y):
        X[i] += 1
    s1, s2, s3 = [x * b for x in X]
    return s1 - s3


def solve_T(a, b):
    INF = 10**18
    res = INF
    for x in (b // 3, -(-b // 3)):
        s1 = x * a
        y = b - x
        x1, x2 = a // 2, (a + 1) // 2
        s2, s3 = x1 * y, x2 * y
        Ss = (s1, s2, s3)
        res = min(res, max(Ss) - min(Ss))
    return res


ans = min(solve_T(h, w), solve_T(w, h), solve_ll(h, w), solve_ll(w, h))
print(ans)

-# =パターン -x, y = divmod(h, 3) -if y == 0: -    x1, x2, x3 = x, x, x -elif y == 1: -    x1, x2, x3 = x + 1, x, x -else: -    x1, x2, x3 = x + 1, x + 1, x -s1, s2, s3 = [x * w for x in (x1, x2, x3)] -ans = s1 - s3 -# llパターン -x, y = divmod(w, 3) -if y == 0: -    x1, x2, x3 = x, x, x -elif y == 1: -    x1, x2, x3 = x + 1, x, x -else: -    x1, x2, x3 = x + 1, x + 1, x -s1, s2, s3 = [x * h for x in (x1, x2, x3)] -ans = min(ans, s1 - s3) -# トパターン -x = -(-w // 3) -s1 = x * h -y = w - x -x1, x2 = h // 2, (h + 1) // 2 -s2, s3 = x1 * y, x2 * y -Ss = (s1, s2, s3) -ans = min(ans, max(Ss) - min(Ss)) -# トパターン -x = w // 3 -s1 = x * h -y = w - x -x1, x2 = h // 2, (h + 1) // 2 -s2, s3 = x1 * y, x2 * y -Ss = (s1, s2, s3) -ans = min(ans, max(Ss) - min(Ss)) -# Tパターン -x = -(-h // 3) -s1 = x * w -y = h - x -x1, x2 = w // 2, (w + 1) // 2 -s2, s3 = x1 * y, x2 * y -Ss = (s1, s2, s3) -ans = min(ans, max(Ss) - min(Ss)) -# Tパターン -x = h // 3 -s1 = x * w -y = h - x -x1, x2 = w // 2, (w + 1) // 2 -s2, s3 = x1 * y, x2 * y -Ss = (s1, s2, s3) -ans = min(ans, max(Ss) - min(Ss)) + + +def solve_ll(a, b): +    x, y = divmod(a, 3) +    X = [x] * 3 +    for i in range(y): +        X[i] += 1 +    s1, s2, s3 = [x * b for x in X] +    return s1 - s3 + + +def solve_T(a, b): +    INF = 10**18 +    res = INF +    for x in (b // 3, -(-b // 3)): +        s1 = x * a +        y = b - x +        x1, x2 = a // 2, (a + 1) // 2 +        s2, s3 = x1 * y, x2 * y +        Ss = (s1, s2, s3) +        res = min(res, max(Ss) - min(Ss)) +    return res + + +ans = min(solve_T(h, w), solve_T(w, h), solve_ll(h, w), solve_ll(w, h))