def answer(H,W,ans):



    for x in range(1,W):

        y1 = H // 2

        Sa1 = H * x

        Sb1 = (W - x) * y1

        Sc1 = (W - x) * (H - y1)

        M = max(Sa1,Sb1,Sc1)

        m = min(Sa1,Sb1,Sc1)



        y2 = (W - x) // 2

        Sa2 = H * x

        Sb2 = H * y2

        Sc2 = H * (W - x - y2)

        M2 = max(Sa2,Sb2,Sc2)

        m2 = min(Sa2,Sb2,Sc2)



        if ans > min(M-m,M2-m2):

            ans = min(M-m,M2-m2)



    return ans



if __name__ == '__main__':

    H,W = [int(i) for i in input().split()]

    ans = H * W

    ans = answer(H,W,ans)



    H,W = W,H



    if answer(H,W,ans) < ans:

        ans = answer(H,W,ans)



    print(ans)

def answer(H,W,ans):

    global ans_list

    for x in range(1,W):

        y1 = H // 2

        S1 = [H * x,(W - x) * y1,(W - x) * (H - y1)]

        ans_list.append(max(S1)-min(S1))



        y2 = (W - x) // 2

        S2 = [H * x,H * y2,H * (W - x - y2)]

        ans_list.append(max(S2)-min(S2))



if __name__ == '__main__':

    H,W = [int(i) for i in input().split()]

    ans_list = []

    answer(H,W,ans_list)

    answer(W,H,ans_list)



    print((min(ans_list)))

def answer(H, W, ans):
    for x in range(1, W):
        y1 = H // 2
        Sa1 = H * x
        Sb1 = (W - x) * y1
        Sc1 = (W - x) * (H - y1)
        M = max(Sa1, Sb1, Sc1)
        m = min(Sa1, Sb1, Sc1)
        y2 = (W - x) // 2
        Sa2 = H * x
        Sb2 = H * y2
        Sc2 = H * (W - x - y2)
        M2 = max(Sa2, Sb2, Sc2)
        m2 = min(Sa2, Sb2, Sc2)
        if ans > min(M - m, M2 - m2):
            ans = min(M - m, M2 - m2)
    return ans


if __name__ == "__main__":
    H, W = [int(i) for i in input().split()]
    ans = H * W
    ans = answer(H, W, ans)
    H, W = W, H
    if answer(H, W, ans) < ans:
        ans = answer(H, W, ans)
    print(ans)

def answer(H, W, ans):
    global ans_list
    for x in range(1, W):
        y1 = H // 2
        S1 = [H * x, (W - x) * y1, (W - x) * (H - y1)]
        ans_list.append(max(S1) - min(S1))
        y2 = (W - x) // 2
        S2 = [H * x, H * y2, H * (W - x - y2)]
        ans_list.append(max(S2) - min(S2))


if __name__ == "__main__":
    H, W = [int(i) for i in input().split()]
    ans_list = []
    answer(H, W, ans_list)
    answer(W, H, ans_list)
    print((min(ans_list)))

+    global ans_list -        Sa1 = H * x -        Sb1 = (W - x) * y1 -        Sc1 = (W - x) * (H - y1) -        M = max(Sa1, Sb1, Sc1) -        m = min(Sa1, Sb1, Sc1) +        S1 = [H * x, (W - x) * y1, (W - x) * (H - y1)] +        ans_list.append(max(S1) - min(S1)) -        Sa2 = H * x -        Sb2 = H * y2 -        Sc2 = H * (W - x - y2) -        M2 = max(Sa2, Sb2, Sc2) -        m2 = min(Sa2, Sb2, Sc2) -        if ans > min(M - m, M2 - m2): -            ans = min(M - m, M2 - m2) -    return ans +        S2 = [H * x, H * y2, H * (W - x - y2)] +        ans_list.append(max(S2) - min(S2)) -    ans = H * W -    ans = answer(H, W, ans) -    H, W = W, H -    if answer(H, W, ans) < ans: -        ans = answer(H, W, ans) -    print(ans) +    ans_list = [] +    answer(H, W, ans_list) +    answer(W, H, ans_list) +    print((min(ans_list)))