# https://atcoder.jp/contests/arc026/tasks/arc026_2

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



def main():

  h,w=LI()



  ans=inf

  for i in range(h+1):

    a=i*w

    b=(h-i+1)//2*w

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

    ans=min(ans,max(a,b,c)-min(a,b,c))



    a=i*w

    b=(h-i)*((w+1)//2)

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

    ans=min(ans,max(a,b,c)-min(a,b,c))



  for i in range(w+1):

    a=i*h

    b=(w-i+1)//2*h

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

    ans=min(ans,max(a,b,c)-min(a,b,c))



    a=i*h

    b=(w-i)*((h+1)//2)

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

    ans=min(ans,max(a,b,c)-min(a,b,c))



  return ans



# main()

print((main()))

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return [int(x) for x in sys.stdin.readline().split()]

# def LF(): return [float(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def F(): return float(sys.stdin.readline())

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



def main():

  h,w=LI()

  ans=[]



  h1=h//3

  h2=(h-h1)//2

  h3=h-(h1+h2)

  ans.append(max(h1,h2,h3)*w-min(h1,h2,h3)*w)



  w1=w//3

  w2=(w-w1)//2

  w3=w-(w1+w2)

  ans.append(max(w1,w2,w3)*h-min(w1,w2,w3)*h)



  mn=inf

  for i in range(1,h):

    a1=w*i

    w1=w//2

    a2=w1*(h-i)

    w2=w-w1

    a3=w2*(h-i)

    mn=min(mn,max(a1,a2,a3)-min(a1,a2,a3))

  ans.append(mn)



  mn=inf

  for i in range(1,w):

    a1=h*i

    h1=h//2

    a2=h1*(w-i)

    h2=h-h1

    a3=h2*(w-i)

    mn=min(mn,max(a1,a2,a3)-min(a1,a2,a3))

  ans.append(mn)



  return min(ans)



# main()

print((main()))

# https://atcoder.jp/contests/arc026/tasks/arc026_2
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


def main():
    h, w = LI()
    ans = inf
    for i in range(h + 1):
        a = i * w
        b = (h - i + 1) // 2 * w
        c = (h - i) // 2 * w
        ans = min(ans, max(a, b, c) - min(a, b, c))
        a = i * w
        b = (h - i) * ((w + 1) // 2)
        c = (h - i) * (w // 2)
        ans = min(ans, max(a, b, c) - min(a, b, c))
    for i in range(w + 1):
        a = i * h
        b = (w - i + 1) // 2 * h
        c = (w - i) // 2 * h
        ans = min(ans, max(a, b, c) - min(a, b, c))
        a = i * h
        b = (w - i) * ((h + 1) // 2)
        c = (w - i) * (h // 2)
        ans = min(ans, max(a, b, c) - min(a, b, c))
    return ans


# main()
print((main()))

import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I():
    return int(sys.stdin.readline())


def F():
    return float(sys.stdin.readline())


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


def main():
    h, w = LI()
    ans = []
    h1 = h // 3
    h2 = (h - h1) // 2
    h3 = h - (h1 + h2)
    ans.append(max(h1, h2, h3) * w - min(h1, h2, h3) * w)
    w1 = w // 3
    w2 = (w - w1) // 2
    w3 = w - (w1 + w2)
    ans.append(max(w1, w2, w3) * h - min(w1, w2, w3) * h)
    mn = inf
    for i in range(1, h):
        a1 = w * i
        w1 = w // 2
        a2 = w1 * (h - i)
        w2 = w - w1
        a3 = w2 * (h - i)
        mn = min(mn, max(a1, a2, a3) - min(a1, a2, a3))
    ans.append(mn)
    mn = inf
    for i in range(1, w):
        a1 = h * i
        h1 = h // 2
        a2 = h1 * (w - i)
        h2 = h - h1
        a3 = h2 * (w - i)
        mn = min(mn, max(a1, a2, a3) - min(a1, a2, a3))
    ans.append(mn)
    return min(ans)


# main()
print((main()))

-# https://atcoder.jp/contests/arc026/tasks/arc026_2 +# def LF(): return [float(x) for x in sys.stdin.readline().split()] + + +def F(): +    return float(sys.stdin.readline()) -    ans = inf -    for i in range(h + 1): -        a = i * w -        b = (h - i + 1) // 2 * w -        c = (h - i) // 2 * w -        ans = min(ans, max(a, b, c) - min(a, b, c)) -        a = i * w -        b = (h - i) * ((w + 1) // 2) -        c = (h - i) * (w // 2) -        ans = min(ans, max(a, b, c) - min(a, b, c)) -    for i in range(w + 1): -        a = i * h -        b = (w - i + 1) // 2 * h -        c = (w - i) // 2 * h -        ans = min(ans, max(a, b, c) - min(a, b, c)) -        a = i * h -        b = (w - i) * ((h + 1) // 2) -        c = (w - i) * (h // 2) -        ans = min(ans, max(a, b, c) - min(a, b, c)) -    return ans +    ans = [] +    h1 = h // 3 +    h2 = (h - h1) // 2 +    h3 = h - (h1 + h2) +    ans.append(max(h1, h2, h3) * w - min(h1, h2, h3) * w) +    w1 = w // 3 +    w2 = (w - w1) // 2 +    w3 = w - (w1 + w2) +    ans.append(max(w1, w2, w3) * h - min(w1, w2, w3) * h) +    mn = inf +    for i in range(1, h): +        a1 = w * i +        w1 = w // 2 +        a2 = w1 * (h - i) +        w2 = w - w1 +        a3 = w2 * (h - i) +        mn = min(mn, max(a1, a2, a3) - min(a1, a2, a3)) +    ans.append(mn) +    mn = inf +    for i in range(1, w): +        a1 = h * i +        h1 = h // 2 +        a2 = h1 * (w - i) +        h2 = h - h1 +        a3 = h2 * (w - i) +        mn = min(mn, max(a1, a2, a3) - min(a1, a2, a3)) +    ans.append(mn) +    return min(ans)