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

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