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