//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 922337203685477580LL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} //head int n, m; int ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; if(~n&1 and ~m&1) { cout << 0 << endl; } else { if(n%4 == 3 and m%4 == 3 and n > 4 and m > 4) { ans = n/4+m/4; ans <<= 1; n -= 6; m -= 6; } if(~n&1) { cout << (n>>2) << endl; } else if(~m&1) { cout << (m>>2) << endl; } else { cout << ((n>>2) + (m>>2))+ans << endl; } } }