def min_value(w, h):

	ans = float('inf')

	for i in range(1, h):

		a = w*i

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

		v_b = (h-i)*w - v_t

		v_re = max(a, v_t, v_b) - min(a, v_t, v_b)

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

		h_r = (h-i)*w-h_l

		h_re = max(a, h_l, h_r) - min(a, h_l, h_r)

		ans = min(ans, v_re, h_re)

	return ans



def resolve():

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

	a = min_value(w, h)

	b = min_value(h, w)

	print((min(a, b)))

resolve()
def calc(w, h):

	v = float('inf')

	a = w * h

	for i in range(1, h):

		h_a = w*i

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

		h_c = a - h_a - h_b

		h_max = max(h_a, h_b, h_c)

		h_min = min(h_a, h_b, h_c)

		v = min(v, h_max - h_min)

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

		v_c = a - h_a - v_b

		v_max = max(h_a, v_b, v_c)

		v_min = min(h_a, v_b, v_c)

		v = min(v, v_max - v_min)

	return v



def resolve():

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

	print((min(calc(h, w), calc(w, h))))

resolve()
def min_value(w, h):
    ans = float("inf")
    for i in range(1, h):
        a = w * i
        v_t = (h - i) // 2 * w
        v_b = (h - i) * w - v_t
        v_re = max(a, v_t, v_b) - min(a, v_t, v_b)
        h_l = (h - i) * (w // 2)
        h_r = (h - i) * w - h_l
        h_re = max(a, h_l, h_r) - min(a, h_l, h_r)
        ans = min(ans, v_re, h_re)
    return ans


def resolve():
    h, w = list(map(int, input().split()))
    a = min_value(w, h)
    b = min_value(h, w)
    print((min(a, b)))


resolve()

def calc(w, h):
    v = float("inf")
    a = w * h
    for i in range(1, h):
        h_a = w * i
        h_b = (h - i) // 2 * w
        h_c = a - h_a - h_b
        h_max = max(h_a, h_b, h_c)
        h_min = min(h_a, h_b, h_c)
        v = min(v, h_max - h_min)
        v_b = w // 2 * (h - i)
        v_c = a - h_a - v_b
        v_max = max(h_a, v_b, v_c)
        v_min = min(h_a, v_b, v_c)
        v = min(v, v_max - v_min)
    return v


def resolve():
    h, w = list(map(int, input().split()))
    print((min(calc(h, w), calc(w, h))))


resolve()

-def min_value(w, h): -    ans = float("inf") +def calc(w, h): +    v = float("inf") +    a = w * h -        a = w * i -        v_t = (h - i) // 2 * w -        v_b = (h - i) * w - v_t -        v_re = max(a, v_t, v_b) - min(a, v_t, v_b) -        h_l = (h - i) * (w // 2) -        h_r = (h - i) * w - h_l -        h_re = max(a, h_l, h_r) - min(a, h_l, h_r) -        ans = min(ans, v_re, h_re) -    return ans +        h_a = w * i +        h_b = (h - i) // 2 * w +        h_c = a - h_a - h_b +        h_max = max(h_a, h_b, h_c) +        h_min = min(h_a, h_b, h_c) +        v = min(v, h_max - h_min) +        v_b = w // 2 * (h - i) +        v_c = a - h_a - v_b +        v_max = max(h_a, v_b, v_c) +        v_min = min(h_a, v_b, v_c) +        v = min(v, v_max - v_min) +    return v -    a = min_value(w, h) -    b = min_value(h, w) -    print((min(a, b))) +    print((min(calc(h, w), calc(w, h))))