#include <stdio.h>

int main()
{
    long long n,m,count;
    scanf("%I64d%I64d",&n,&m);
    if(n<=m/2)
        {
            count=n;
            m-=n*2;
            count+=m/4;
        }
    else
        count=m/2;
    printf("%I64d\n",count);

    return 0;
}
