#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    long m,n,s;
    while(~scanf("%ld %ld",&n,&m))
    {
        s=0;
        s+=n;
        m=m-2*n;
        s+=m/4;
        printf("%ld\n",s);
    }
}
