void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    long scc = min(n, m/2);
    scc += (m - 2 * scc) / 4;

    scc.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;