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

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

    print((0))

else:

    x=[]

    for i in range(1,w):

        sub=[]

        sub.append([h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)])

        #sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)])

        sub.append([h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)])

        #sub.append([h*i,(w-i)*(h//2+1),h*(w-i)-(w-i)*(h//2+1)])

        for j in sub:

            x.append(max(j)-min(j))

    for i in range(1,h):

        sub=[]

        sub.append([w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)])

        #sub.append([w*i,w*((h-i)//2+1),w*(h-i)-w*((h-i)//2+1)])

        sub.append([w*i,(h-i)*(w//2),w*(h-i)-(h-i)*(w//2)])

        #sub.append([w*i,(h-i)*(w//2+1),w*(h-i)-(h-i)*(w//2+1)])

        for j in sub:

            x.append(max(j)-min(j))

    print((min(x)))

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

x=[]

for i in range(1,w):

    x1=[h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]

    x1.sort()

    x.append(x1[-1]-x1[0])

    x2=[h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]

    x2.sort()

    x.append(x2[-1]-x2[0])

for i in range(1,h):

    x1=[w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)]

    x1.sort()

    x.append(x1[-1]-x1[0])

    x2=[w*i,(h-i)*(w//2),w*(h-i)-(h-i)*(w//2)]

    x2.sort()

    x.append(x2[-1]-x2[0])

print((min(x)))

h, w = list(map(int, input().split()))
if h % 3 == 0 or w % 3 == 0:
    print((0))
else:
    x = []
    for i in range(1, w):
        sub = []
        sub.append([h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)])
        # sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)])
        sub.append([h * i, (w - i) * (h // 2), h * (w - i) - (w - i) * (h // 2)])
        # sub.append([h*i,(w-i)*(h//2+1),h*(w-i)-(w-i)*(h//2+1)])
        for j in sub:
            x.append(max(j) - min(j))
    for i in range(1, h):
        sub = []
        sub.append([w * i, w * ((h - i) // 2), w * (h - i) - w * ((h - i) // 2)])
        # sub.append([w*i,w*((h-i)//2+1),w*(h-i)-w*((h-i)//2+1)])
        sub.append([w * i, (h - i) * (w // 2), w * (h - i) - (h - i) * (w // 2)])
        # sub.append([w*i,(h-i)*(w//2+1),w*(h-i)-(h-i)*(w//2+1)])
        for j in sub:
            x.append(max(j) - min(j))
    print((min(x)))

h, w = list(map(int, input().split()))
x = []
for i in range(1, w):
    x1 = [h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)]
    x1.sort()
    x.append(x1[-1] - x1[0])
    x2 = [h * i, (w - i) * (h // 2), h * (w - i) - (w - i) * (h // 2)]
    x2.sort()
    x.append(x2[-1] - x2[0])
for i in range(1, h):
    x1 = [w * i, w * ((h - i) // 2), w * (h - i) - w * ((h - i) // 2)]
    x1.sort()
    x.append(x1[-1] - x1[0])
    x2 = [w * i, (h - i) * (w // 2), w * (h - i) - (h - i) * (w // 2)]
    x2.sort()
    x.append(x2[-1] - x2[0])
print((min(x)))

-if h % 3 == 0 or w % 3 == 0: -    print((0)) -else: -    x = [] -    for i in range(1, w): -        sub = [] -        sub.append([h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)]) -        # sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)]) -        sub.append([h * i, (w - i) * (h // 2), h * (w - i) - (w - i) * (h // 2)]) -        # sub.append([h*i,(w-i)*(h//2+1),h*(w-i)-(w-i)*(h//2+1)]) -        for j in sub: -            x.append(max(j) - min(j)) -    for i in range(1, h): -        sub = [] -        sub.append([w * i, w * ((h - i) // 2), w * (h - i) - w * ((h - i) // 2)]) -        # sub.append([w*i,w*((h-i)//2+1),w*(h-i)-w*((h-i)//2+1)]) -        sub.append([w * i, (h - i) * (w // 2), w * (h - i) - (h - i) * (w // 2)]) -        # sub.append([w*i,(h-i)*(w//2+1),w*(h-i)-(h-i)*(w//2+1)]) -        for j in sub: -            x.append(max(j) - min(j)) -    print((min(x))) +x = [] +for i in range(1, w): +    x1 = [h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)] +    x1.sort() +    x.append(x1[-1] - x1[0]) +    x2 = [h * i, (w - i) * (h // 2), h * (w - i) - (w - i) * (h // 2)] +    x2.sort() +    x.append(x2[-1] - x2[0]) +for i in range(1, h): +    x1 = [w * i, w * ((h - i) // 2), w * (h - i) - w * ((h - i) // 2)] +    x1.sort() +    x.append(x1[-1] - x1[0]) +    x2 = [w * i, (h - i) * (w // 2), w * (h - i) - (h - i) * (w // 2)] +    x2.sort() +    x.append(x2[-1] - x2[0]) +print((min(x)))