import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

long n, m;

long cal(long use)
{
	long s = n + use / 2;
	long c2 = (m - use) / 2;
	return min(s, c2);
}

void main() {
	auto nm = readln.chomp.split.map!(to!long);
	n = nm[0];
	m = nm[1];
	long left = 0;
	long right = m + 1;
	while (right - left > 2) {
		long midL = (left * 2 + right) / 3;
		long midR = (left + right * 2) / 3;
		long resL = midL.cal;
		long resR = midR.cal;
		if (resL < resR) {
			left = midL;
		} else {
			right = midR;
		}
	}
	debug stderr.writeln([left, right]);
	debug stderr.writeln([left.cal, cal((left * 2 + right) / 3), cal((left + right * 2) / 3), right.cal]);
	// cal((left + right * 2) / 3) がそれ？　よく分からないので全部試す…
	long ans = 0;
	for (long ite = left; ite < right; ++ite) {
		ans = max(ans, ite.cal);
	}
	ans.writeln;
}

