#include <stdio.h>

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