#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll z=b*2;
    if(a>=z)
    {
        cout<<a<<endl;
    }
    else
    {

        cout<<a+(b-a*2)/4<<endl;
    }
    return 0;
}
