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

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