# Original solution
def main():
    a, b = list(map(int, input().split()))
    if (a % 3 ==0) | (b % 3 ==0):
        ans = 0
    else:
        anss = []
        s1 = (b // 3 + 1) * a
        s2 = (b - (b // 3 + 1)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 - 1) * a
        s2 = (b - (b // 3) + 1) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3 + 1)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        # b a
        t = a
        a = b
        b = t
        s1 = (b // 3 + 1) * a
        s2 = (b - (b // 3 + 1)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 - 1) * a
        s2 = (b - (b // 3) + 1) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3 + 1)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        ans = min(anss)

    print(ans)
    
main()

# Optimized solution
a, b = list(map(int, input().split()))
if (a % 3 ==0) | (b % 3 ==0):
    ans = 0
else:
    anss = []
    s1 = (b // 3 + 1) * a
    s2 = (b - (b // 3 + 1)) * (a // 2)
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3) * a
    s2 = (b - (b // 3)) * (a // 2)
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3 - 1) * a
    s2 = (b - (b // 3) + 1) * (a // 2)
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3) * a
    s2 = (b // 3) * a
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3) * a
    s2 = (b // 3 + 1) * a
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    # b a
    t = a
    a = b
    b = t
    s1 = (b // 3 + 1) * a
    s2 = (b - (b // 3 + 1)) * (a // 2)
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3) * a
    s2 = (b - (b // 3)) * (a // 2)
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3 - 1) * a
    s2 = (b - (b // 3) + 1) * (a // 2)
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3) * a
    s2 = (b // 3) * a
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    s1 = (b // 3) * a
    s2 = (b // 3 + 1) * a
    s3 = a * b - s1 - s2
    anss.append(max(s1, s2, s3) - min(s1, s2, s3))

    ans = min(anss)

print(ans)