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