#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
int main()
{
    ll n,m;
    while(~scanf("%lld %lld",&n,&m))
    {
        if(n * 2 >= m)
        {
            printf("%lld\n",m/2);
        }
        else {
            printf("%lld\n",n + (m -  2 * n)/4);
        }
    }
}
