import java.util.*


fun subSolver(f: Int, s: Int): Int {
    val m = s/2;
    if(s % 2 == 0){
        return m;
    }
    else
    {
        val n = f/3;
        if(m > n)
            return m + n + 1;
        else 
            return 2 * m + 1;
    }
}

fun solv(h: Int, w: Int): Int {
	if( h%3 == 0 || w %3 == 0){
		return 0;
	}
	else {
    	val a = subSolver(h,w);
    	val b = subSolver(w,h);
    	if( a < b)
			return a;
    	else 
	    	return b;
	}
}

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
 	val res = solv(h,w); 
  	println(res);
}