#import <stdio.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define ABS(a) ((a)>0?(a):(-(a)))

long fl(double x) {
    long n = (long)x;
    return n + (((x != n) && (x < 0)) ? -1 : 0);
}

long r(double x) {
    double n = fl(x);
    double d = x - n;
    return ((x>=0)&&(d<0.5))||((x<0)&&(d<=0.5)) ? n : n+1;
}

int main() {
    long H,W;
    scanf("%ld %ld",&H,&W);
    if (W%3==0 || H%3==0) {
        printf("0");
        return 0;
    }
    long min = MIN(H,W);
    if (H%2==0) {
        long x = r(2.0*W/3);
        min = MIN(min, ABS(H/2*x - (W-x)*H));
    }
    if (W%2==0) {
        long x = r(2.0*H/3);
        min = MIN(min, ABS(W/2*x - (H-x)*W));
    }
    if (H%2==1) {
        long n = (H-1)/2;
        for (long x=MAX(1,2.0*W/3-2);x<=MIN(W-1,2.0*W/3+2);x++) {
            min = MIN(min,MAX(ABS((W-x)*H-(n+1)*x),ABS((W-x)*H-n*x)));
        }
    }
    if (W%2==1) {
        long n = (W-1)/2;
        for (long x=MAX(1,2.0*H/3-2);x<=MIN(H-1,2.0*H/3+2);x++) {
            min = MIN(min,MAX(ABS((H-x)*W-(n+1)*x),ABS((H-x)*W-n*x)));
        }
    }
    printf("%ld",min);
}
