#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long long a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF)
	{
		if(a*2>b)
		printf("%lld\n",b/2);
		else if(a*2==b)
		printf("%lld\n",a);
		else
		printf("%lld\n",a+(b-2*a)/4);
	}
	return 0;
}