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(){
	int h = read.to!int;
	int w = read.to!int;
	
	int ans = int.max;
	int 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;
	
	ans.writeln;
	}

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

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

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

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

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

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