#include<stdio.h>
int main()
{
	long long n,m;
	scanf("%lld %lld",&n,&m);
    long long t=m/2;
    if(n>=t)
    printf("%lld\n",t);
    else
    {
    	t=t-n;
    	t=t/2;
    	printf("%lld\n",n+t);
	}
	return 0;
 } 