    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
        long long  a,b,sum;
        sum = 0;
        scanf("%lld %lld",&a,&b);
        if(2*a<=b)
        {
            sum += a;
            b = b - a*2;
            sum += b/4;
        }
        else
        {
            sum += b/2;
        }
        printf("%lld\n",sum);
        return 0;
    }
