#include using namespace std; int main(){ int A,B,i,j; cin >> A >> B; i=(A+2*B)/3; j=(2*A+B-1)/3; cout << i-j << endl; return 0; }