#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	long long int a, b, sum=0, i;
	scanf("%lld %lld",&a, &b);
	if(a>b)
	printf("%lld",b/2);
	else if(a<b&&a>b/2)
	printf("%lld",b/2);
	else
	printf("%lld",a+(b-2*a)/4);
	return 0;	
}