#include using namespace std; const long long INF = 1000000000000; int main(){ long long N, M; cin >> N >> M; if (N == 3 && M == 3){ cout << 0 << endl; } else { long long a = ((N + 1) / 2) * ((M + 1) / 2); long long b = ((N + 1) / 2) * (M / 2); long long c = (N / 2) * ((M + 1) / 2); long long d = (N / 2) * (M / 2); long long m = min({a, b, c, d}); a -= m; b -= m; c -= m; d -= m; long long ans = INF; for (int i = 0; i <= min((long long) 2, a); i++){ for (int j = 0; j <= min((long long) 2, b); j++){ for (int k = 0; k <= min((long long) 2, c); k++){ for (int l = 0; l <= min((long long) 2, d); l++){ long long a2 = a - i; long long b2 = b - j; long long c2 = c - k; long long d2 = d - l; if (!(i == 2 && j == 2) && !(1 == 2 && k == 2) && !(j == 2 && l == 2) && !(k == 2 && l == 2)){ if (a2 % 2 == 0 && b2 % 2 == 0 && c2 % 2 == 0 && d2 % 2 == 0){ if ((a2 + b2 + c2 + d2) % 4 == 0){ ans = min(ans, (a2 + b2 + c2 + d2) / 4); } } } } } } } cout << ans << endl; } }