import sys



inf = 1<<60

ans = inf



def solve():

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

    calc(H, W)

    calc(W, H)

    print(ans)



def calc(H, W):

    global ans



    for a in range(1, W):

        s0 = a * H



        s1 = H * ((W - a + 1) // 2)

        s2 = H * ((W - a) // 2)



        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))



        s1 = (W - a) * ((H + 1) // 2)

        s2 = (W - a) * (H // 2)



        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) 



if __name__ == '__main__':

    solve()
import sys



inf = 1<<60

ans = inf



def solve():

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

    

    calc(H, W)

    calc(W, H)



    print(ans)



def calc(H, W):

    global ans

    x = W // 3



    s0 = x * H

    s1 = H * ((W - x + 1) // 2)

    s2 = H * ((W - x) // 2)



    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))



    s1 = (W - x) * ((H + 1) // 2)

    s2 = (W - x) * (H // 2)



    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))



    x = (W + 2) // 3



    s0 = x * H

    s1 = H * ((W - x + 1) // 2)

    s2 = H * ((W - x) // 2)



    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))



    s1 = (W - x) * ((H + 1) // 2)

    s2 = (W - x) * (H // 2)



    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))



if __name__ == '__main__':

    solve()
import sys

inf = 1 << 60
ans = inf


def solve():
    H, W = list(map(int, input().split()))
    calc(H, W)
    calc(W, H)
    print(ans)


def calc(H, W):
    global ans
    for a in range(1, W):
        s0 = a * H
        s1 = H * ((W - a + 1) // 2)
        s2 = H * ((W - a) // 2)
        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))
        s1 = (W - a) * ((H + 1) // 2)
        s2 = (W - a) * (H // 2)
        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))


if __name__ == "__main__":
    solve()

import sys

inf = 1 << 60
ans = inf


def solve():
    H, W = list(map(int, input().split()))
    calc(H, W)
    calc(W, H)
    print(ans)


def calc(H, W):
    global ans
    x = W // 3
    s0 = x * H
    s1 = H * ((W - x + 1) // 2)
    s2 = H * ((W - x) // 2)
    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))
    s1 = (W - x) * ((H + 1) // 2)
    s2 = (W - x) * (H // 2)
    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))
    x = (W + 2) // 3
    s0 = x * H
    s1 = H * ((W - x + 1) // 2)
    s2 = H * ((W - x) // 2)
    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))
    s1 = (W - x) * ((H + 1) // 2)
    s2 = (W - x) * (H // 2)
    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))


if __name__ == "__main__":
    solve()

-    for a in range(1, W): -        s0 = a * H -        s1 = H * ((W - a + 1) // 2) -        s2 = H * ((W - a) // 2) -        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) -        s1 = (W - a) * ((H + 1) // 2) -        s2 = (W - a) * (H // 2) -        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) +    x = W // 3 +    s0 = x * H +    s1 = H * ((W - x + 1) // 2) +    s2 = H * ((W - x) // 2) +    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) +    s1 = (W - x) * ((H + 1) // 2) +    s2 = (W - x) * (H // 2) +    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) +    x = (W + 2) // 3 +    s0 = x * H +    s1 = H * ((W - x + 1) // 2) +    s2 = H * ((W - x) // 2) +    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) +    s1 = (W - x) * ((H + 1) // 2) +    s2 = (W - x) * (H // 2) +    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))