using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using static System.Console;
using static System.Math;
class Simple {
    private int H, W;
    private string[] a;
    void Solve() {
        //input
        H = io.Int;
        W = io.Int;
        //cal
        var ans = long.MaxValue;
        //type A1 横横横
        ans = Min(ans, A(H, W));
        //type A2 縦縦縦
        ans = Min(ans, A(W, H));
        //type B1 縦横横
        ans = Min(ans, B(H, W));
        //rtpe B2 横縦縦
        ans = Min(ans, B(W, H));
        //ret
        WriteLine(ans);
    }
    long A(long a, long b) => a % 3 == 0 ? 0 : b;
    long B(long a, long b) {
        var ret = long.MaxValue;
        var aIsOdd = a % 2 != 0;
        for(int i = 1; i <= b - 1; ++i) {
            var v1 = a * i;
            var v2 = (b - i) * (a / 2);
            var v3 = a % 2 == 0 ? (b - i) * (a / 2) : (b - i) * (a / 2) + 1;
            ret = Min(ret, myMax(v1, v2, v3) - myMin(v1, v2, v3));
        }
        return ret;
    }
    long myMin(params long[] a) => a.Min();
    long myMax(params long[] a) => a.Max();
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = true
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}
