def func(H,W):

    area = H * W



    half_H = int(H/2)

    half_W = int(W/2)  

    

    res = 10000000

    

    # よこ

    # T

    for x in range(1,W):

        S1 = H * x

        S2_T = (W - x) * half_H

        S3_T = area - S1 - S2_T

        

        S2_2 = H * int((W - x)/2)

        S3_2 = area - S1 - S2_2

        

        tmpres_T = max(S1, S2_T, S3_T) - min(S1, S2_T, S3_T)

        tmpres_2 = max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2)

        

        if tmpres_T < res:

            res = tmpres_T

        if tmpres_2 < res:

            res = tmpres_2

    # たて

    # T

    for y in range(1,H):

        S1 = W * y

        S2_T = (H - y) * half_W

        S3_T = area - S1 - S2_T

        

        S2_2 = W * int((H - y)/2)

        S3_2 = area - S1 - S2_2

        

        tmpres_T = max(S1, S2_T, S3_T) - min(S1, S2_T, S3_T)

        tmpres_2 = max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2)

        

        if tmpres_T < res:

            res = tmpres_T

        if tmpres_2 < res:

            res = tmpres_2

    

    return res



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

print((func(H,W)))
def func(H,W):

    if H % 3 == 0:

        return 0



    H_3 = int(H/3)

    S1 = H_3 * W

    S2 = (H - H_3) * int(W/2)

    S3 = H * W - S1 - S2 

    

    res1 = max(S1, S2, S3) - min(S1, S2, S3)

    

    H_3_1 = int(H/3) + 1

    S1 = H_3_1 * W

    S2 = (H - H_3_1) * int(W/2)

    S3 = H * W - S1 - S2 

    

    res2 = max(S1, S2, S3) - min(S1, S2, S3)

    

    return min(res1 ,res2)

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

print((min(func(H,W), func(W,H), H, W)))
def func(H, W):
    area = H * W
    half_H = int(H / 2)
    half_W = int(W / 2)
    res = 10000000
    # よこ
    # T
    for x in range(1, W):
        S1 = H * x
        S2_T = (W - x) * half_H
        S3_T = area - S1 - S2_T
        S2_2 = H * int((W - x) / 2)
        S3_2 = area - S1 - S2_2
        tmpres_T = max(S1, S2_T, S3_T) - min(S1, S2_T, S3_T)
        tmpres_2 = max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2)
        if tmpres_T < res:
            res = tmpres_T
        if tmpres_2 < res:
            res = tmpres_2
    # たて
    # T
    for y in range(1, H):
        S1 = W * y
        S2_T = (H - y) * half_W
        S3_T = area - S1 - S2_T
        S2_2 = W * int((H - y) / 2)
        S3_2 = area - S1 - S2_2
        tmpres_T = max(S1, S2_T, S3_T) - min(S1, S2_T, S3_T)
        tmpres_2 = max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2)
        if tmpres_T < res:
            res = tmpres_T
        if tmpres_2 < res:
            res = tmpres_2
    return res


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

def func(H, W):
    if H % 3 == 0:
        return 0
    H_3 = int(H / 3)
    S1 = H_3 * W
    S2 = (H - H_3) * int(W / 2)
    S3 = H * W - S1 - S2
    res1 = max(S1, S2, S3) - min(S1, S2, S3)
    H_3_1 = int(H / 3) + 1
    S1 = H_3_1 * W
    S2 = (H - H_3_1) * int(W / 2)
    S3 = H * W - S1 - S2
    res2 = max(S1, S2, S3) - min(S1, S2, S3)
    return min(res1, res2)


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

-    area = H * W -    half_H = int(H / 2) -    half_W = int(W / 2) -    res = 10000000 -    # よこ -    # T -    for x in range(1, W): -        S1 = H * x -        S2_T = (W - x) * half_H -        S3_T = area - S1 - S2_T -        S2_2 = H * int((W - x) / 2) -        S3_2 = area - S1 - S2_2 -        tmpres_T = max(S1, S2_T, S3_T) - min(S1, S2_T, S3_T) -        tmpres_2 = max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2) -        if tmpres_T < res: -            res = tmpres_T -        if tmpres_2 < res: -            res = tmpres_2 -    # たて -    # T -    for y in range(1, H): -        S1 = W * y -        S2_T = (H - y) * half_W -        S3_T = area - S1 - S2_T -        S2_2 = W * int((H - y) / 2) -        S3_2 = area - S1 - S2_2 -        tmpres_T = max(S1, S2_T, S3_T) - min(S1, S2_T, S3_T) -        tmpres_2 = max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2) -        if tmpres_T < res: -            res = tmpres_T -        if tmpres_2 < res: -            res = tmpres_2 -    return res +    if H % 3 == 0: +        return 0 +    H_3 = int(H / 3) +    S1 = H_3 * W +    S2 = (H - H_3) * int(W / 2) +    S3 = H * W - S1 - S2 +    res1 = max(S1, S2, S3) - min(S1, S2, S3) +    H_3_1 = int(H / 3) + 1 +    S1 = H_3_1 * W +    S2 = (H - H_3_1) * int(W / 2) +    S3 = H * W - S1 - S2 +    res2 = max(S1, S2, S3) - min(S1, S2, S3) +    return min(res1, res2) -print((func(H, W))) +print((min(func(H, W), func(W, H), H, W)))