#include using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0;i<(n);i++) int main(){ LL N,M; cin>>N>>M; LL ans=0; while(true){ if(N%2==0 && M%2==0){ ans=0; break; } if(N&2==1) swap(N,M); if(N%2==1){ if(N%4!=3 || M%4!=3){ ans=N/4+M/4; break; } if(N==3 && M==3){ ans=0; break; } ans=N/4+M/4+2; break; } if(N%4==0){ ans=N/4; break;} ans=0; break; } cout<