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

if h*w%3:

  ans=min(h,w)

  for x in range(1,w+1):

    ans=min(ans,max(h*x,h//2*(w-x),(h-h//2)*(w-x))-min(h*x,h//2*(w-x),(h-h//2)*(w-x)))

  h,w=w,h

  for x in range(1,w+1):

    ans=min(ans,max(h*x,h//2*(w-x),(h-h//2)*(w-x))-min(h*x,h//2*(w-x),(h-h//2)*(w-x)))

  print(ans)

else:print((0))
h,w=list(map(int,input().split()))

def f(x,y):

    ret=(1 if x%3 else 0)*y

    for i in range(1,x):

        f=sorted((i*y,y//2*(x-i),(1+y)//2*(x-i)))

        ret=min(ret,f[2]-f[0])

    return ret

print((min(f(h,w),f(w,h))))
h, w = list(map(int, input().split()))
if h * w % 3:
    ans = min(h, w)
    for x in range(1, w + 1):
        ans = min(
            ans,
            max(h * x, h // 2 * (w - x), (h - h // 2) * (w - x))
            - min(h * x, h // 2 * (w - x), (h - h // 2) * (w - x)),
        )
    h, w = w, h
    for x in range(1, w + 1):
        ans = min(
            ans,
            max(h * x, h // 2 * (w - x), (h - h // 2) * (w - x))
            - min(h * x, h // 2 * (w - x), (h - h // 2) * (w - x)),
        )
    print(ans)
else:
    print((0))

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


def f(x, y):
    ret = (1 if x % 3 else 0) * y
    for i in range(1, x):
        f = sorted((i * y, y // 2 * (x - i), (1 + y) // 2 * (x - i)))
        ret = min(ret, f[2] - f[0])
    return ret


print((min(f(h, w), f(w, h))))

-if h * w % 3: -    ans = min(h, w) -    for x in range(1, w + 1): -        ans = min( -            ans, -            max(h * x, h // 2 * (w - x), (h - h // 2) * (w - x)) -            - min(h * x, h // 2 * (w - x), (h - h // 2) * (w - x)), -        ) -    h, w = w, h -    for x in range(1, w + 1): -        ans = min( -            ans, -            max(h * x, h // 2 * (w - x), (h - h // 2) * (w - x)) -            - min(h * x, h // 2 * (w - x), (h - h // 2) * (w - x)), -        ) -    print(ans) -else: -    print((0)) + + +def f(x, y): +    ret = (1 if x % 3 else 0) * y +    for i in range(1, x): +        f = sorted((i * y, y // 2 * (x - i), (1 + y) // 2 * (x - i))) +        ret = min(ret, f[2] - f[0]) +    return ret + + +print((min(f(h, w), f(w, h))))