#include <stdio.h>

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