import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long h = read.to!long;
	long w = read.to!long;
	
	long ans = long.max;
	long p;
	
	p = p1(h, w); if(p < ans) ans = p;
	p = p2(h, w); if(p < ans) ans = p;
	p = p3(h, w); if(p < ans) ans = p;
	p = p4(h, w); if(p < ans) ans = p;
	p = p5(h, w); if(p < ans) ans = p;
	p = p6(h, w); if(p < ans) ans = p;
	p = p7(h, w); if(p < ans) ans = p;
	p = p8(h, w); if(p < ans) ans = p;
	
	ans.writeln;
	}

long p1(long h, long w){
	long a = (h / 3) * w;
	long b = (h / 3) * w;
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p2(long h, long w){
	long a = h * (w / 3);
	long b = h * (w / 3);
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p3(long h, long w){
	long a = (h / 3) * w;
	long b = (h - h / 3) * (w / 2);
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p4(long h, long w){
	long a = h * (w / 3);
	long b = (h / 2) * (w - w / 3);
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p5(long h, long w){
	long a = ((h + 2) / 3) * w;
	long b = (h - (h + 2) / 3) * (w / 2);
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p6(long h, long w){
	long a = h * ((w + 2) / 3);
	long b = (h / 2) * (w - (w + 2) / 3);
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p7(long h, long w){
	long a = ((h + 2) / 3) * w;
	long b = ((h + 2) / 3) * w;
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

long p8(long h, long w){
	long a = h * ((w + 2) / 3);
	long b = h * ((w + 2) / 3);
	long c = h * w - a - b;
	return max(a, b, c) - min(a, b, c);
	}

