#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
long long  n,m;
using namespace std;
int main()
{
	while(cin>>n>>m){
		if(n>=m/2)
		 cout<<m/2<<endl;
		else
		cout<<n+(m-2*n)/4<<endl;
		 
	}

}