#include<cstdio>
#include<map>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int sum=0;
        if(m>=n*2)
        {
            sum+=n;
            m-=n*2;
        }
        sum+=m/4;
        printf("%d\n",sum);
    }
    return 0;
}
