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 x = n * 2 + m;
	
	long y = x / 4;
	
	long ans;
	if(y > n) ans = y;
	else ans = m / 2;
	
	ans.writeln;
	}