#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m, n;
    cin >> n >> m;
    int count = 0;
    if (n <= 2 * m)
    {
        m = m - 2 * n;
        count += n;
        n = 0;
        count += m / 4;
    }
    else
    {
        count += m / 2;
    }
    printf("%d\n",count);
    return 0;
}
