import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	long n, m;
	{
		long[] tmp = readln.chomp.split.map!(to!long).array;
		n = tmp[0], m = tmp[1];
		}
	
	long ans;
	
	/*
	long x = n * 2 + m;
	
	long y = x / 4;
	
	if(y > n) ans = y;
	else ans = m / 2;
	
	*/
	
	if(n < m / 2) ans = n + (m - n * 2) / 4;
	else ans = m / 2;
	
	
	ans.writeln;
	}