console.log((args=>{
  const [H,W] = args.trim().split` `.map(v=>v|0);
  let min = Math.min( H%3&&W, W%3&&H );
  if ( !min ) return min;
  const Hmin = ((H-min*2)/3)|0, Hmax = min+((H-min)/3)|0;
  for ( let i = Hmin; i < Hmax; i++ ) {
    const Wmin = W>>1, Wmax = W-Wmin;
    const s = Math.max( (H-i) * Wmax, i * W ) - Math.min( (H-i) * Wmin, i * W )
    if ( s < min ) min = s;
  }
  const Wmin = ((W-min*2)/3)|0, Wmax = min+((W-min)/3)|0;
  for ( let i = Wmin; i < Wmax; i++ ) {
    const Hmin = H>>1, Hmax = H-Hmin;
    const s = Math.max( (W-i) * Hmax, i * H ) - Math.min( (W-i) * Hmin, i * H )
    if ( s < min ) min = s;
  }
  return min;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
