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



if h%3 == 0 or w%3 == 0:

    print((0))

    exit()



#print(h, w)

min_ = float('inf')

for i in range(1, h):

    s1 = w*i

    s2 = (h-i)*(w//2)

    s3 = (h-i)*(w-w//2)

    d = max([s1, s2, s3]) - min([s1, s2, s3])

    #print(i, s1, s2, s3, d)

    min_ = min(min_, d)



    s2 = ((h-i)//2)*w

    s3 = ((h-i) - (h-i)//2)*w

    d = max([s1, s2, s3]) - min([s1, s2, s3])

    #print(i, s1, s2, s3, d)

    min_ = min(min_, d)



#print('-')



for i in range(1, w):

    s1 = h*i

    s2 = (w-i)*(h//2)

    s3 = (w-i)*(h-h//2)

    d = max([s1, s2, s3]) - min([s1, s2, s3])

    #print(i, s1, s2, s3, d)

    min_ = min(min_, d)



    s2 = ((w-i)//2)*h

    s3 = ((w-i) - (w-i)//2)*h

    d = max([s1, s2, s3]) - min([s1, s2, s3])

    #print(i, s1, s2, s3, d)

    min_ = min(min_, d)



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

ans = 10**18

for i in range(1, h):

    S1 = i*w

    # tate

    if h-i >= 2:

        p = (h-i)//2

        q = h-(h-i)//2-i

        S2 = p*w

        S3 = q*w

        M = max([S1, S2, S3])

        m = min([S1, S2, S3])

        ans = min(ans, M-m)

        #if i == 1:

            #print(S1, S2, S3)

    # yoko

    S2 = (h-i)*(w//2)

    S3 = (h-i)*(w-w//2)

    M = max([S1, S2, S3])

    m = min([S1, S2, S3])

    ans = min(ans, M-m)



for i in range(1, w):

    S1 = h*i

    # yoko

    if w-i >= 2:

        p = (w-i)//2

        q = w-(w-i)//2-i

        S2 = h*p

        S3 = h*q

        M = max([S1, S2, S3])

        m = min([S1, S2, S3])

        ans = min(ans, M-m)

    # tate

    S2 = (h//2)*(w-i)

    S3 = (h-h//2)*(w-i)

    M = max([S1, S2, S3])

    m = min([S1, S2, S3])

    ans = min(ans, M-m)

print(ans)

h, w = list(map(int, input().split()))
if h % 3 == 0 or w % 3 == 0:
    print((0))
    exit()
# print(h, w)
min_ = float("inf")
for i in range(1, h):
    s1 = w * i
    s2 = (h - i) * (w // 2)
    s3 = (h - i) * (w - w // 2)
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    # print(i, s1, s2, s3, d)
    min_ = min(min_, d)
    s2 = ((h - i) // 2) * w
    s3 = ((h - i) - (h - i) // 2) * w
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    # print(i, s1, s2, s3, d)
    min_ = min(min_, d)
# print('-')
for i in range(1, w):
    s1 = h * i
    s2 = (w - i) * (h // 2)
    s3 = (w - i) * (h - h // 2)
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    # print(i, s1, s2, s3, d)
    min_ = min(min_, d)
    s2 = ((w - i) // 2) * h
    s3 = ((w - i) - (w - i) // 2) * h
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    # print(i, s1, s2, s3, d)
    min_ = min(min_, d)
print(min_)

h, w = list(map(int, input().split()))
ans = 10**18
for i in range(1, h):
    S1 = i * w
    # tate
    if h - i >= 2:
        p = (h - i) // 2
        q = h - (h - i) // 2 - i
        S2 = p * w
        S3 = q * w
        M = max([S1, S2, S3])
        m = min([S1, S2, S3])
        ans = min(ans, M - m)
        # if i == 1:
        # print(S1, S2, S3)
    # yoko
    S2 = (h - i) * (w // 2)
    S3 = (h - i) * (w - w // 2)
    M = max([S1, S2, S3])
    m = min([S1, S2, S3])
    ans = min(ans, M - m)
for i in range(1, w):
    S1 = h * i
    # yoko
    if w - i >= 2:
        p = (w - i) // 2
        q = w - (w - i) // 2 - i
        S2 = h * p
        S3 = h * q
        M = max([S1, S2, S3])
        m = min([S1, S2, S3])
        ans = min(ans, M - m)
    # tate
    S2 = (h // 2) * (w - i)
    S3 = (h - h // 2) * (w - i)
    M = max([S1, S2, S3])
    m = min([S1, S2, S3])
    ans = min(ans, M - m)
print(ans)

-if h % 3 == 0 or w % 3 == 0: -    print((0)) -    exit() -# print(h, w) -min_ = float("inf") +ans = 10**18 -    s1 = w * i -    s2 = (h - i) * (w // 2) -    s3 = (h - i) * (w - w // 2) -    d = max([s1, s2, s3]) - min([s1, s2, s3]) -    # print(i, s1, s2, s3, d) -    min_ = min(min_, d) -    s2 = ((h - i) // 2) * w -    s3 = ((h - i) - (h - i) // 2) * w -    d = max([s1, s2, s3]) - min([s1, s2, s3]) -    # print(i, s1, s2, s3, d) -    min_ = min(min_, d) -# print('-') +    S1 = i * w +    # tate +    if h - i >= 2: +        p = (h - i) // 2 +        q = h - (h - i) // 2 - i +        S2 = p * w +        S3 = q * w +        M = max([S1, S2, S3]) +        m = min([S1, S2, S3]) +        ans = min(ans, M - m) +        # if i == 1: +        # print(S1, S2, S3) +    # yoko +    S2 = (h - i) * (w // 2) +    S3 = (h - i) * (w - w // 2) +    M = max([S1, S2, S3]) +    m = min([S1, S2, S3]) +    ans = min(ans, M - m) -    s1 = h * i -    s2 = (w - i) * (h // 2) -    s3 = (w - i) * (h - h // 2) -    d = max([s1, s2, s3]) - min([s1, s2, s3]) -    # print(i, s1, s2, s3, d) -    min_ = min(min_, d) -    s2 = ((w - i) // 2) * h -    s3 = ((w - i) - (w - i) // 2) * h -    d = max([s1, s2, s3]) - min([s1, s2, s3]) -    # print(i, s1, s2, s3, d) -    min_ = min(min_, d) -print(min_) +    S1 = h * i +    # yoko +    if w - i >= 2: +        p = (w - i) // 2 +        q = w - (w - i) // 2 - i +        S2 = h * p +        S3 = h * q +        M = max([S1, S2, S3]) +        m = min([S1, S2, S3]) +        ans = min(ans, M - m) +    # tate +    S2 = (h // 2) * (w - i) +    S3 = (h - h // 2) * (w - i) +    M = max([S1, S2, S3]) +    m = min([S1, S2, S3]) +    ans = min(ans, M - m) +print(ans)