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