#include <iostream>
using namespace std;

typedef long long ll;

int main() {
    ll n, m;
    while( cin >> n >> m ) {
        if( m <= 2 * n ) {
            cout << m / 2 << endl;
        }
        else {
            ll temp = m - 2 * n;
            cout << n + temp / 4 << endl;
        }
    }
    return 0;
}