A and B are preparing themselves for programming contests.An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?

The first line contains two integers n and m (0 ≤ n, m ≤ 5·105) — the number of experienced participants and newbies that are present at the training session.

Print the maximum number of teams that can be formed.

NoteLet's represent the experienced players as XP and newbies as NB.In the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).In the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.Queue_at_the_School
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (Math.Min(x[0], x[1])*2 <= Math.Max(x[0], x[1]))
            {
                Console.WriteLine((Math.Min(x[0], x[1]) + Math.Min(x[0], x[1]) * 2) / 3);
            }
           else if (Math.Min(x[0], x[1]) * 2 > Math.Max(x[0], x[1]))
            {
                Console.WriteLine((Math.Min(x[0], x[1]) + Math.Max(x[0], x[1])) / 3);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sp = Console.ReadLine().Split();
            int n = int.Parse(sp[0]);
            int m = int.Parse(sp[1]);
            var tsk = new Task();
            Console.WriteLine(tsk.Sol(n,m));
        }
    }

    class Task
    {
        public int Sol(int n, int m)
        {
            int rs1 = 0;
            for(int i = 0; i <= n; ++i)
                rs1 = Math.Max( rs1, i + Math.Min((n - i) / 2, m - 2*i));

            return rs1;
        }
    }
}

using System;
  public class Program
    {
        public static void Main(string[] args)
        {
            int freshers, veterans;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                veterans = int.Parse(input[0]);
                freshers = int.Parse(input[1]);
                if(veterans>freshers)
                {
                    int temp = veterans;
                    veterans = freshers;
                    freshers = temp;
                }
            }
            freshers = freshers - veterans;
            if (veterans <= freshers)
                Console.WriteLine(veterans);
            else
            {
                veterans -= freshers;
                Console.WriteLine(((veterans / 3*2) + (freshers) + (veterans % 3 == 2 ? 1 : 0)));
            }
        }
    }

namespace topCoder
{
	using System;
	using System.Collections.Generic;

	class p3
	{
		static void Main(string[] args)
		{
			//p1 o = new p1();
			//o.foo();

			//p2 o = new p2();
			//o.foo();

			p3 o = new p3();
			o.foo();
		}
		public void foo()
		{
			string[] sp = Console.ReadLine().Split(' ');
			int n = int.Parse(sp[0]);
			int m = int.Parse(sp[1]);

			int x = Math.Min(n, m);
			for (int i = x; i >= 0; i--)
			{
				if (n + m - i - i >= i)
				{
					Console.WriteLine(i);
					break;
				}
			}
		}
	}
}

using System;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			//Console.SetIn(new StreamReader(@"C:\CodeForces\input.txt"));
			new Template().Solve();
			Console.ReadLine();
		}

		private void Solve()
		{
			var xp = cin.NextInt();
			var nb = cin.NextInt();
			var teams = xp;
			while (teams > 0)
			{
				var xpLeft = xp - teams;
				var c = Math.Min(xpLeft, teams);
				var lower = 2*teams - c;
				if (nb >= lower)
				{
					Console.WriteLine(teams);
					return;
				}
				teams--;
			}
			Console.WriteLine(0);
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string Next()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}
	}
}

using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var max = 0;
            for (int k = 0; k*2 <= n; k++)
            {
                var rem = n - k * 2;
                var rem2 = m - k;
                if (rem2 < 0)
                    continue;
                var min = Math.Min(rem, rem2 / 2);
                max = Math.Max(k + min, max);
            }
            IO.Printer.Out.WriteLine(max);

        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            var init = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var n = init[0];
            var m = init[1];

            var ans = 0;
            while(true)
            {
                if (ans > Math.Min(n, m) || n + m < ans * 3)
                    break;
                ans++;
            }

            Console.WriteLine(ans - 1);
            Console.ReadLine();
        }

    }
}

/*
 * Created by SharpDevelop.
 * User: pvkcse_tup
 * Date: 3/1/2015
 * Time: 10:46 AM
 * student At : Accet,KKdi
 *
 */
using System;

namespace cdf
{
	class Program
	{
		public static void Main(string[] args)
		{
			Team_Problem_Solver test = new Team_Problem_Solver();
			test.Get_Data();
			test.Solve();
		}
	}
	class Team_Problem_Solver
	{
		public long[] INP = new long[2];
		public string[] s;
		public void Get_Data()
		{
			s = Console.ReadLine().Split(' ');
			INP[0] = Convert.ToInt64(s[0]);
			INP[1] = Convert.ToInt64(s[1]);
		}
		public void Solve()
		{
			long ans = (INP[0]+INP[1])/3;
			if (ans > INP[0] && ans > INP[1])
				Console.WriteLine(Math.Min(INP[0],INP[1]).ToString());
			else if (ans > INP[1])
				Console.WriteLine(INP[1].ToString());
			else if (ans > INP[0])
				Console.WriteLine(INP[0].ToString());
			else
				Console.WriteLine(ans.ToString());
		}

	}
}

using System;

class C519 {
    public static void Main() {
        var line = Console.ReadLine().Split();
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        if (n + n < m) m = n + n;
        if (m + m < n) n = m + m;
        Console.WriteLine((n + m) / 3);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            IO io = new IO();

            int i_N = io.ReadNextInt();
            int i_M = io.ReadNextInt();

            int i_Ans = 0;

            for (int i = 0; ; i++)
            {
                if (i_N > i_M)
                {
                    if (i_N >= 2 && i_M >= 1)
                    {
                        i_N -= 2;
                        i_M--;
                        i_Ans++;
                    }
                    else
                    {
                        break;
                    }
                }

                else
                {
                    if (i_N >= 1 && i_M >= 2)
                    {
                        i_N--;
                        i_M -= 2;
                        i_Ans++;
                    }
                    else
                    {
                        break;
                    }

                }
            }

            io.PutStr(i_Ans);
        }
    }

    class IO
    {
        private static Queue<string> currentLineTokens = new Queue<string>();
        private static string[] ReadAndSplitLine()
        {
            return Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }
        public int ReadNextInt()
        {
            return int.Parse(ReadToken());
        }
        public long ReadNextLong()
        {
            return long.Parse(ReadToken());
        }

        public int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        public long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        public string ReadStr()
        {
            return Console.ReadLine();
        }
        public string[] ReadStrArr()
        {
            return Console.ReadLine().Split(' ');
        }
        public int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), s => int.Parse(s));
        }
        public long[] ReadLongArr()
        {
            return Array.ConvertAll<string, long>(Console.ReadLine().Split(' '), s => long.Parse(s));
        }
        public void PutStr(string str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(int str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(long str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(double str)
        {
            Console.WriteLine(str);
        }

        public static string ReadToken()
        {
            while (currentLineTokens.Count == 0)
                currentLineTokens = new Queue<string>(ReadAndSplitLine());
            return currentLineTokens.Dequeue();
        }
    }
}

using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        if (a[1] < a[0] * 2) a[0] = (a[1] + a[0]) / 3;
        Console.WriteLine(a[0]);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pr1
{
    class Program
    {
        static void Main()
        {
            var a=  Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
            int n=a[0],m=a[1],j=0;
            while(n!=0&&m!=0)
            {
                while(n>=m&&n>1&&m>0)
                {
                    n-=2;
                    m--;
                    j++;
                }
                while(m>=n&&m>1&&n>0)
                {
                    m-=2;
                    n--;
                    j++;
                }
                if(n==1&&m==1)
                    break;
            }
            Console.Write(j);

        }

    }
}

using System;

namespace Sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] d = Console.ReadLine().Split(' ');
            int n = int.Parse(d[0]), m = int.Parse(d[1]), result = 0;

            for (int i = 0; i <= n; i++)
            {
                int leftn = n - i;
                int leftm = m - 2 * i;

                if (leftm >= 0) result = Math.Max(result, i + Math.Min(leftm, leftn / 2));
            }

            Console.WriteLine(result);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace training
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = Convert.ToInt32(str.Remove(str.IndexOf(' ')));
            int m = Convert.ToInt32(str.Substring(str.IndexOf(' ') + 1));
            int schet = 0;
            while ((n >= 2 && m >= 1) || (n >= 1 && m >= 2))
            {
                if (n > m)
                {
                    n -= 2;
                    --m;
                    ++schet;
                }
                else
                {
                    --n;
                    m -= 2;
                    ++schet;
                }
            }
            Console.WriteLine(schet);
        }
    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if (n == 0 || m == 0) Console.WriteLine(0);
            else if (n / m <= 0.5) Console.WriteLine(n);
            else if (m / n <= 0.5) Console.WriteLine(m);
            else
            {
               Console.WriteLine((int)(n + m) / 3);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Test
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] s1 = s.Split(' ');
            int n = int.Parse(s1[0]);
            int m = int.Parse(s1[1]);
            int sum = 0;
            while(!(n==0||m==0||(n==1&&m==1)))
            {
                if (m > n)
                {
                    m = m - 2;
                    n = n - 1;
                    sum++;
                }
                else {
                    n = n - 2;
                    m = m - 1;
                    sum++;
                }
            }
            Console.WriteLine( sum);

        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            // The numbers of experienced and new guys
            var aNums = Console.ReadLine().Split().Select(int.Parse).ToArray();

            // Display results
            Console.WriteLine(Math.Min((aNums[0] + aNums[1]) / 3, Math.Min(aNums[0], aNums[1])));
        }
    }
}

using System;

namespace CSharp
{
    public class _519C
    {
        public static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();

            int n = int.Parse(tokens[0]);
            int m = int.Parse(tokens[1]);

            Console.WriteLine(Math.Min((n + m) / 3, Math.Min(n, m)));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_b_V
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            Int64 n = Convert.ToInt64(s[0]);
            Int64 m = Convert.ToInt64(s[1]);
            int count = 0;
            while(n > 0 && m > 0)
            {
                if (n == 1 && m == 1)
                {
                    break;
                }
                if (n >= m)
                {
                    n -= 2;
                    m--;
                    count++;
                }
                else
                {
                    n--;
                    m-= 2;
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		if(N*2<=M){
			Console.WriteLine(N);
			return;
		}
		int ans=0;
		for(int i=N-1;i>=0;i--){
			if(M>=i && (M+(N-i))>=2*i){
				ans=i;break;
			}
		}
		Console.WriteLine(ans);

	}
	int N,M;
	public Sol(){
		var d=ria();
		N=d[0];M=d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

using System;
using System.Linq;

namespace Codeforces
{
    public class Program
    {
        private const int MAXN = 8000;

        public static void Main(string[] args)
        {
            var arr = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = arr[0];
            var m = arr[1];

            int count = 0;
            while (n > 0 && m > 0)
            {
                if (n == 1 && m == 1)
                {
                    break;
                }

                if (n > m)
                {
                    n -= 2;
                    m -= 1;
                    count++;
                }
                else
                {
                    m -= 2;
                    n -= 1;
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] r = Console.ReadLine().Split(' ');
            int n = int.Parse(r[0]); //xp
            int m = int.Parse(r[1]); //nb
            int max = int.MinValue;
            for (int i = 0; i <= n; i++) //xp nb nb
            {
                int tekBr = i + Math.Min((n - i) / 2, m - 2 * i);
                if (tekBr > max) max = tekBr;
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] r = Console.ReadLine().Split(' ');
            int n = int.Parse(r[0]); //xp
            int m = int.Parse(r[1]); //nb
            int max = int.MinValue;
            for (int i = 0; i <= n && m - 2 * i >= 0; i++)  //i je broj timova (xp nb nb)
            {
                int tekBr = i + Math.Min((n - i) / 2, m - 2 * i);
                if (tekBr > max) max = tekBr;
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    internal class Program
    {

        private static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int ans = 0;

            int op = 0;
            int nov = 0;

            if (n <= 1 && m <= 1) ans = 0;
            else
            {
                if (n == m)
                {
                    ans = 2 * (m / 3);

                    if (m % 3 == 2) ans++;
                }
                else
                {
                    op = n/2;
                    nov = m/2;
                    if (op <= m && nov <= n)
                    {
                        ans = n/3 + m/3;
                        if ((n%3 == 2 && m%3 != 0) || (m%3 == 2 && n%3 != 0)) ans ++;
                    }
                    else
                    {
                        if (n > m)
                        {
                            ans = n / 2;

                            if (m >= op)
                            {
                                ans += op;
                                m -= op;
                                if (m >= 2 && n % 2 == 1) ans++;
                            }
                            else
                            {
                                ans = m % op;
                            }

                        }

                        if (n < m)
                        {
                            nov = m / 2;

                            if (n >= nov)
                            {
                                ans += nov;
                                n -= nov;
                                if (n >= 2 && m % 2 == 1) ans++;
                            }
                            else
                            {
                                ans = n % nov;
                            }

                        }
                    }

                }
            }

            Console.WriteLine(ans);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace CodeTrening
{
    class Program
    {
        static void Main(string[] args)
        {
            string []s = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(s[0]);
            int m = Convert.ToInt32(s[1]);
            int ans = 0;
            if (n > 1 || m > 1)
            {
                while (true)
                {
                    if (n == 0) { break; }
                    if (m == 0) { break; }
                    if (n == 1 && m == 1) break;
                    if (n > m) { ans++; n -= 2; m--; }
                    else { ans++; n--; m -= 2; }
                }
            }
            Console.WriteLine(  ans);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] l = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            int n = l[0], m = l[1];

            int cnt = 0;
            while(Math.Min(n,m)>0)
            {
                if(n>m)
                {
                    n -= 2;m--;
                }
                else
                {
                    n--;m -= 2;
                }
                if (n<0||m<0)
                    break;
                cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

using System;
 class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                a = int.Parse(input[0]);
                b = int.Parse(input[1]);
            }
            int pairs = 0;
            if(a!=b)
            {
                if(a>b) { int temp = a; a = b; b = temp; }
                if (b - a >= a) { pairs = a; a = b = 0; }
                else { pairs = b - a; a -= pairs; b = a; }
            }
            Console.WriteLine(pairs += a * 2 / 3);
        }
    }

using System;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();
            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);
            int ToF = 0;
            int div = 0;
            if (n % 2 == 0) { div = n / 2; }
            else
            {
                div = n / 2 + 1;
            }
            if (n >= k * 2)
            {
                Console.WriteLine(k);
            }

            else
            {
                for (int i = 0; i <= div; i++)
                {
                    if (k >= n * 2 - i * 3)
                    {
                        Console.WriteLine(n - i);
                        ToF = 1;
                        break;
                    }
                }
                if (ToF == 0)
                {
                    Console.WriteLine("0");
                }

            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abtraining
{
    class Program
    {
        static int n, m;
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ');
            n = int.Parse(arr[0]);
            m = int.Parse(arr[1]);

            if(n < m){
                int aux = n;
                n = m;
                m = aux;
            }

            var count = n / 2;
            if(count >= m){
                Console.Write(m);
            } else {
                m -= count;
                count += (m + n % 2) / 3;
                Console.Write(count);
            }
        }
    }
}

using System;
using System.Collections.Generic;

namespace Prog
{
    class Program
    {
        static void Main(string[] args)
        {
           int n, m, res;

            string[] str = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            n = Convert.ToInt32(str[0]);
            m = Convert.ToInt32(str[1]);

            if (m < n)
            {
                res = n;
                n = m;
                m = res;
            }

            res = (n + m) / 3 < n ? (n + m) / 3 : n;
            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using static System.Math;

// http://codeforces.com/problemset/problem/519/C
public class C___A_and_B_and_Team_Training
{
    private static void Solve()
    {
        int a = ReadInt();
        int b = ReadInt();

        int teams = 0;
        while ((a > 0 && b > 1) || (a > 1 && b > 0))
        {
            if (a > b)
            {
                a -= 2;
                b -= 1;
            } else
            {
                a -= 1;
                b -= 2;
            }
            teams++;
        }

        Write(teams);
    }

    #region Main

    private static TextReader reader;
    private static TextWriter writer;

    public static void Main()
    {
#if DEBUG

        //reader = new StreamReader("C:\\Users\\Axel\\Desktop\\input.txt");
        reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;

        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());

        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            Solve();

            //var thread = new Thread(new String_Task().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion Main

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string Read()
    {
        while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(Read());
    }

    public static long ReadLong()
    {
        return long.Parse(Read());
    }

    public static double ReadDouble()
    {
        return double.Parse(Read(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array) writer.WriteLine(a);
    }

    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    private static T[] Init<T>(int size) where T : new()
    {
        var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret;
    }

    #endregion Read / Write
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = data[0];
            var m = data[1];
            var res = 0;
            while (n != 0 && m != 0 && (n != 1 || m != 1))
            {
                //if(n == 0 || m == 0 || (n == 1 && m == 1))
                //    break;
                if (n > m)
                {
                    n -= 2;
                    m -= 1;
                    res++;
                }
                else
                {
                    n -= 1;
                    m -= 2;
                    res++;
                }
            }

            Console.WriteLine(res);
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace A_and_B_and_Team_Training
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int m = Next();

            int count = 0;

            while (n > 0 && m > 0 && n + m > 2)
            {
                if (n < m)
                {
                    count++;
                    n--;
                    m -= 2;
                }
                else
                {
                    count++;
                    n -= 2;
                    m--;
                }
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), m = int.Parse(input[1]);
            int result = 0;
            while (true)
            {
                if (n <= m && n >= 1 && m >= 2)
                {
                    result++;
                    n--;
                    m -= 2;
                }
                else if (n > m && n >= 2 && m >= 1)
                {
                    result++;
                    n -= 2;
                    m--;
                }
                else
                    break;
            }
            Console.WriteLine(result);
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        private static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]),
                m = int.Parse(s[1]),
                answer = 0;

            while (n >= 1 && m >= 2 || n >= 2 && m >= 1)
            {
                if (n >= 1 && m >= 2 && n <= m)
                {
                    n--;
                    m -= 2;
                }
                else
                {
                    m--;
                    n -= 2;
                }
                answer++;
            }
            Console.WriteLine(answer);
        }
    }
}

using System;
using System.Linq;

namespace _1A
{
    class Program
    {
        static void Main()
        {
            var input1 =Console.ReadLine().Split(' ').Select(long.Parse);
            var a = input1.First();
            var b = input1.Last();
            var c = (a + b)/3;
            var min = a > b ? b : a;
            if(c<=min)
                Console.WriteLine(c);
            else
            {
                Console.WriteLine(min);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
public class Test
{
    public static void Main()
    {
        // your code goes here
        //int n = int.Parse(Console.ReadLine());
        int[] arr = Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
        int n = arr[0];
        int m = arr[1];
        int maxGroup = -1;
        for(int i = 0 ; i <= n ; i++){
            //if i is exp person single group
            int groupA = Math.Min(m,2*i);
            groupA = groupA / 2;
            int groupB = Math.Min(m - groupA * 2,(n-i)/2);
            maxGroup = Math.Max(groupA + groupB,maxGroup);
        }
        Console.WriteLine(maxGroup);
    }
}

using System;
using System.Collections.Generic;

public class Program
{
    static void Main()
    {
        var args = Console.ReadLine().Split(' ');
        var n = int.Parse(args[0]);
        var m = int.Parse(args[1]);

        var min = n < m ? n : m;

        var result1 = (m + n)/3;
        var result = min < result1 ? min : result1;
        Console.WriteLine(result);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]), ans = 0;
            for (int t1 = 0; t1 <= n / 2; t1++) {
                int t2 = Math.Min(n - 2 * t1, (m - t1) / 2);
                if (t1 <= m && t1 + t2 > ans) {
                    ans = t1 + t2;
                }
            }
            Console.Write(ans);
           //  Console.ReadKey();
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace CodeForces.PRACTICE
{
    // A and B and Team Training (greedy, implementation, math, number theory)
    class _519C
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            if (m >= 2 * n) Console.WriteLine(n);
            else if (n >= 2 * m) Console.WriteLine(m);
            else Console.WriteLine((n + m) / 3);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abTeamTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            uint n = uint.Parse(s[0]);
            uint m = uint.Parse(s[1]);
            uint t = 0;
            while (n > 0 && m > 0 && (n > 1 || m > 1))
            {
                if (n >= m)
                {
                    n -= 2; m -= 1;
                }
                else
                {
                    m -= 2; n -= 1;
                }
                t++;
            }
            Console.WriteLine(t);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;
using System.Text.RegularExpressions;

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
#if  LOCAL_TEST
        private readonly TextReader inputStream = new StreamReader("input.txt");
#else
        private readonly TextReader inputStream = Console.In;
#endif
#if  FBHC_TEST
        private readonly TextWriter outputStream = new StreamWriter("output.txt");
#else
        private readonly TextWriter outputStream = Console.Out;
#endif

        private string[] tokens;
        private int pointer;

        public char NextChar()
        {
            try
            {
                var c = inputStream.Read();

                if (c < 0)
                    c = 0;

                return (char)c;
            }
            catch (IOException)
            {
                return '\0';
            }
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            var res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

        public IEnumerable<T> NextSeq<T>(long n)
        {
            for (var i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            var ienum = o as IEnumerable;

            if (ienum != null && typeof(T) != typeof(string))
            {
                var first = true;

                foreach (var iev in ienum)
                {
                    if (!first && iev != null)
                        Print(" ");

                    Print(iev);

                    first = false;
                }

            }
            else
            {
                outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
            }

        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static string Reverse(this string s)
        {
            var charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static long MODPower(this int x, long y, long mod)
        {
            long answ = 1;

            if (y == 0)
                return answ;
            if (y % 2 == 1)
                answ *= x;

            answ *= MODPower(x, y / 2, mod) * MODPower(x, y / 2, mod);

            answ %= mod;

            return answ;
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<int, IList<T>, T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval(i, self);

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<int, T> fval)
        {
            return self.Fill((x, slf) => fval(x));
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            return self.Fill(x => fval());
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }

        public static int Xor1n(this int n)
        {
            return (n >> 1) & 1 ^ ((n & 1) > 0 ? 1 : n);
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = unchecked(hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode()));
            hash = unchecked(hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode()));
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (var io = new MyIo())
            {
                try
                {
                    new Program(io)
                        .Solve();
                }
                catch (Exception e)
                {
                    io.PrintLine(e.Message + "\r\n" + e.StackTrace);

                    throw;
                }
            }
        }

        #endregion

        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {

            int n = io.NextInt();
            int m = io.NextInt();
            int x = 0;
            int dx = 0;

            do
            {
                if (m > n)
                {
                    int tmp = m;
                    m = n;
                    n = tmp;
                }

                if (m >= 1 && n >= 2)
                {
                    dx = 1;
                    n -= 2;
                    m -= 1;
                }
                else
                    dx = 0;

                x += dx;
            } while (dx > 0);

            io.Print(x);

        }

    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Task
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = Console.ReadLine().Split(' ').Select(e => Convert.ToInt32(e)).ToArray();
            var n = arr[0];
            var m = arr[1];
            int cnt = 0;
            while (true)
            {
                if (n >= m)
                {
                    if (n >= 2 && m >= 1)
                    {
                        n -= 2;
                        m--;
                        cnt++;
                    }
                    else
                        break;
                }
                else
                {
                    if (n >= 1 && m >= 2)
                    {
                        n--;
                        m -= 2;
                        cnt++;
                    }
                    else
                        break;
                }
            }
            Console.Write(cnt);
        }
    }
}

using System;
	public class main {
		public static void Main() {
			int n;
			int m;
			string s = Console.ReadLine();
			n = int.Parse(s.Split()[0]);
			m = int.Parse(s.Split()[1]);
			int res = 0;
			if (n*2<=m) {
				res = n;
			} else if (n>=m*2) {
				res = m;
			} else {
				do {
					if (n<m) {
						int tmp = n;
						n = m;
						m = tmp;
					}
					if (n>=2 && m>=1) {
						n -= 2;
						m--;
						res++;
					}
					else break;
				} while (true);
			}
			Console.WriteLine(res);
		}
	}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Round_294
{
    class Program
    {
        static void Main(string[] args)
        {

            //Chess ch = new Chess();
            //ch.Test();
            //CompilationErrors ce = new CompilationErrors();
            //ce.Test();
            TeamTraining tt = new TeamTraining();
            tt.Test();
        }
    }
    class Chess
    {

        void Count(string[] board,out long  cntb,out long cntw)
        {
            cntb=0;
            cntw=0;
            for(int i=0;i<board.Length;i++)
                for(int j=0;j<board[i].Length;j++)
                {
                    switch(board[i][j])
                    {
                        case 'Q':cntw+=9;break;
                        case 'R': cntw+=5;break;
                        case 'B': cntw+=3;break;
                        case 'N':cntw+=3;break;
                        case 'P':cntw+=1;break;

                        case 'q':cntb+=9;break;
                        case 'r': cntb+=5;break;
                        case 'b': cntb+=3;break;
                        case 'n':cntb+=3;break;
                        case 'p':cntb+=1;break;

                        default:break;
                    }
                }
        }
        public void Test()
        {
            string[]board =new string[8];
            for(int i=0;i<board.Length;i++)
                board[i]=Console.ReadLine();
            long cntb=0;
            long cntw=0;
            Count(board,out cntb,out cntw);
            if(cntb>cntw)Console.WriteLine("Black");
            else if(cntb<cntw)Console.WriteLine("White");
            else Console.WriteLine( "Draw");
        }
    }
    class CompilationErrors
    {
        public void Test()
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = new long[n];
            string[] ss=Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(ss[i]);
            long []b=new long[n-1];
            ss = Console.ReadLine().Split();
            for (int i = 0; i < n-1; i++)
                b[i] = int.Parse(ss[i]);
            long[] c = new long[n - 2];
            ss = Console.ReadLine().Split();
            for (int i = 0; i < n-2; i++)
                c[i] = int.Parse(ss[i]);
            Console.WriteLine(Cmp(a, b));
            Console.WriteLine(Cmp(b,c));
        }
        long Cmp(long []a,long[]b)
        {
            long x = 0;
            for (int i = 0; i < a.Length; i++)
                x = x ^ a[i];
            for (int i = 0; i < b.Length; i++)
                x = x ^ b[i];
            return x;
        }
    }
    class TeamTraining
    {
        public void Test()
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            //long max=0;
            //long cnt =0;
            //for(int i=1;i<=n;i++)
            //{
            //    cnt = i + Min(m - 2 * i, n - i);
            //    if (cnt > max) max = cnt;
            //}
            //Console.WriteLine(max);
            long cnt = 0;
            while(n>0&&m>0)
            {
                if (n > m) n--;
                else m--;
                n--;
                m--;
                if (n < 0 || m < 0) break;
                cnt++;
            }
            Console.WriteLine(cnt);
        }
        int Min(int a,int b)
        {
            return a < b ? a : b;
        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {

        static void Main(string[] args)
        {
            string []arr=new string[2];
            Int64 t1=0, t2=0, total=0;

            arr = Console.ReadLine().Split(' ');
            Int64 n=Convert.ToInt64(arr[0]);
            Int64 m=Convert.ToInt64(arr[1]);

            for(Int64 i=0; i <= n; i++){
                if ((n - i) >= 0 && (m - 2 * i) >= 0)
                {
                    t1 = i;
                    t2 = Math.Min(m - 2 * i, (n - i) / 2);
                    if ((t1 + t2) > total) { total = t1 + t2; }
                }
                else break;
            }
            Console.WriteLine(total);
        }
    }
}

using System;
namespace Contest
{
class MainClass{
   public static void Main (string[] args){
            long n,s=0,k,ss=0;
            string[] st=Console.ReadLine().Split(' ');
            n=long.Parse(st[0]);
            k=long.Parse(st[1]);

            if(n<k)
            {
                long p=k;
                k=n;
                n=p;
            }
            s=(k+n)/3;
            if (s>k)
             s=k;

              Console.WriteLine(s);
    }
}
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prC {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            int n = Next();
            int m = Next();
            int a = 0;
            while(n != 0 && m != 0) {
                if(n > m) {
                    n -= 2;
                    m--;
                }
                else if(m > n || m != 1) {
                    n--;
                    m -= 2;
                }
                else
                    break;
                a++;
            }
            writer.WriteLine(a);

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();

        int ans = 0;
        while (true)
        {
            if (ans > Math.Min(n, m) || n + m < 3 * ans)
                break;
            ans++;
        }
        Write(ans - 1);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("subsequences.in");
        //writer = new StreamWriter("subsequences.out");
#endif
        try
        {
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);
            thread.Start();
            thread.Join();
            //new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace ConsoleApplication252
{
    class Program
    {
        static void Main()
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int k = 0;
            while (true)
            {
                if (n <= 0 || m <= 0 || (n == 1 && m == 1))
                {
                    break;
                }
                if (n <= m)
                {
                    n--;
                    m -= 2;
                    k++;
                }
                else
                {
                    n -= 2;
                    m--;
                    k++;
                }

            }
            Console.WriteLine(k);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace Solving
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                new Solver().Solve();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //Console.ReadKey();
            }
        }
    }

    class Solver {
        public  void Solve() {
            int[] arr = InputReader.ReadIntArr();
            int pro = arr[0], noob = arr[1], countofteam = 0;
            while ((pro >= 1 && noob >= 2) || (pro >= 2 && noob >= 1)) {
                if (pro >= noob && pro >= 2) { pro -= 2; noob--; countofteam++; }
                else if (pro < noob && noob >= 2) { pro--; noob -= 2; countofteam++; }
            }
            Console.WriteLine(countofteam);
            //Console.ReadKey();
        }
    }

    class InputReader {
        public static int[] ReadIntArr() {
            return Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
        }
        public static long[] ReadLongArr() {
            return Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();
        }
        public static double[] ReadDoubleArr() {
            return Console.ReadLine().Split(' ').Select(s => Double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }
        public static string[] ReadSplitString() {
            return Console.ReadLine().Split(' ').ToArray();
        }
        public static int ReadInt() {
            return Int32.Parse(Console.ReadLine());
        }
        public static long ReadLong() {
            return Int64.Parse(Console.ReadLine());
        }
        public static double ReadDouble() {
            return Double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
        }
        public static int[][] ReadIntMatrix(int numberofrows) {
            int[][] matrix = new int[numberofrows][];
            for (int i = 0; i < numberofrows; i++) {
                matrix[i] = ReadIntArr();
            }
            return matrix;
        }
        public static string[] ReadStringLines(int numberoflines) {
            string[] arr = new string[numberoflines];
            for (int i = 0; i < numberoflines; i++) {
                arr[i] = Console.ReadLine().Trim();
            }
            return arr;
        }
    }

    class OutputWriter {
        public static void WriteArray<T>(IEnumerable<T> array) {
            Console.WriteLine(string.Join(" ", array));
        }
        public static void WriteLines<T>(IEnumerable<T> array) {
            foreach (var a in array) { Console.WriteLine(a); }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];

            int T = 0;

            if (m >= n * 2)
            {
                T += n;
            }
            else if (n >= m * 2)
            {
                T += m;
            }
            else
            {
                T = (m + n) / 3;
            }

            Console.WriteLine(T);
        }
    }
}

using System;
using System.Linq;
class Program
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var teams = (nm[0] + nm[1]) / 3;
        Console.WriteLine(Math.Min(teams, Math.Min(nm[0], nm[1])));
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp57
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = inp0[0];
            int n = inp0[1];
            int t = 0;
            while (x>=1&&n>=1)
            {
                if (x==1&&n==1)
                {
                    break;
                }
                    if (x>n)
                    {
                        x -= 2;
                        n--;
                        t++;
                        continue;
                    }
                    else
                    {
                        x--;
                        n -= 2;
                        t++;

                    }

            }
            Console.WriteLine(t);

        }

    }
}

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c)
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string GetString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var a = getList();
			var n = a[0];
			var m = a[1];
			Console.WriteLine(Min(n, Min(m, (n + m) / 3)));
			/*			input.Close();
			output.Close();*/
		}
	}
}

using System;
using System.Linq;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var O = s[0]; var H = s[1];
            int count = 0;
            while ( (O>=2 && H>=1)|| (O>=1 && H>=2))
            {
                count++;
                if (O > H) { O-=2;H--;}
                else { O--; H -= 2; }
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputArray = Array.ConvertAll(Console.ReadLine().Split((char)32), int.Parse);

            Console.WriteLine(Math.Min(inputArray[0], Math.Min(inputArray[1], (inputArray[0] + inputArray[1]) / 3)));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.Queue_at_the_School
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (Math.Min(x[0], x[1])*2 <= Math.Max(x[0], x[1]))
            {
                Console.WriteLine((Math.Min(x[0], x[1]) + Math.Min(x[0], x[1]) * Math.Min(x[0], x[1])) / 3);
            }
           else if (Math.Min(x[0], x[1]) * 2 > Math.Max(x[0], x[1]))
            {
                Console.WriteLine((Math.Min(x[0], x[1]) + Math.Max(x[0], x[1])) / 3);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sp = Console.ReadLine().Split();
            int n = int.Parse(sp[0]);
            int m = int.Parse(sp[1]);
            var tsk = new Task();
            Console.WriteLine(tsk.Sol(n,m));
        }
    }

    class Task
    {
        public int Sol(int n, int m)
        {
            int rs = 0;
            for(int i = 1; i <= n; ++i)
                rs = Math.Max( rs, i + Math.Min((n - i) / 2, m - 2*i));

            return rs;
        }
    }
}

using System;

namespace Ronda7
{
    class BajoPresion
    {
        static void Main(string [] args)
        {
            var sp = Console.ReadLine().Split();
            int n = int.Parse(sp[0]);
            int m = int.Parse(sp[1]);
            int team1 = n;
            int team2 = 0;
            int team4 = m;
            int team5 = 0;
            if( 2 * n >= m){
                team1 = m / 2;
                team2 = (n - m / 2 > 1) ? 1 : 0;
            }
            if( 2 * m >= n){
                team4 = n / 2;
                team5 = (m - n / 2 > 1) ? 1 : 0;
            }
            Console.WriteLine(Math.Max(team1 + team2, team4 + team5));
        }
    }
}

using System;
 public class Program
    {
        public static void Main(string[] args)
        {
            int freshers, veterans;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                veterans = int.Parse(input[0]);
                freshers = int.Parse(input[1]);
                if(veterans>freshers)
                {
                    int temp = veterans;
                    veterans = freshers;
                    freshers = temp;
                }
            }
            freshers = freshers - veterans;
            if (veterans <= freshers)
                Console.WriteLine(veterans);
            else
            {
                veterans -= freshers;
                Console.WriteLine((freshers+2*(veterans/3+(veterans%3==2?1:0))));
            }
        }
    }

using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var max = 0;
            for (int k = 0; k*2 <= n; k++)
            {
                var rem = n - k * 2;
                var rem2 = m - k;
                var min = Math.Min(rem, rem2 / 2);
                max = Math.Max(k + min, max);
            }
            IO.Printer.Out.WriteLine(max);

        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            var init = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var n = init[0];
            var m = init[1];

            var ans = 0;
            while(true)
            {
                if (ans > Math.Min(n, m) || n + m > ans * 3)
                    break;
                ans++;
            }

            Console.WriteLine(ans - 1);
            Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            IO io = new IO();

            int i_N = io.ReadNextInt();
            int i_M = io.ReadNextInt();

            int i_Ans = 0;

            for (int i = 0; ; i++)
            {
                if (i_N > i_M)
                {
                    if (i_N >= 2 && i_M >= 1)
                    {
                        i_N -= 2;
                        i_M--;
                        i_Ans++;
                    }
                    else
                    {
                        break;
                    }
                }

                else
                {
                    if (i_N >= 1 && i_M >= 2)
                    {
                        i_N--;
                        i_M -= 2;
                        i_Ans++;
                    }
                    else
                    {
                        break;
                    }

                }

                io.PutStr(i_Ans);
            }
        }
    }

    class IO
    {
        private static Queue<string> currentLineTokens = new Queue<string>();
        private static string[] ReadAndSplitLine()
        {
            return Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }
        public int ReadNextInt()
        {
            return int.Parse(ReadToken());
        }
        public long ReadNextLong()
        {
            return long.Parse(ReadToken());
        }

        public int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        public long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        public string ReadStr()
        {
            return Console.ReadLine();
        }
        public string[] ReadStrArr()
        {
            return Console.ReadLine().Split(' ');
        }
        public int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), s => int.Parse(s));
        }
        public long[] ReadLongArr()
        {
            return Array.ConvertAll<string, long>(Console.ReadLine().Split(' '), s => long.Parse(s));
        }
        public void PutStr(string str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(int str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(long str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(double str)
        {
            Console.WriteLine(str);
        }

        public static string ReadToken()
        {
            while (currentLineTokens.Count == 0)
                currentLineTokens = new Queue<string>(ReadAndSplitLine());
            return currentLineTokens.Dequeue();
        }
    }
}

using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (a[1] < a[0] * 2) a[0] = (a[1] + a[0]) / 3;
        Console.WriteLine(a[0]);
    }
}

using System;

namespace Sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split(' ');

            int a = int.Parse(st[0]), b = int.Parse(st[1]);

            Console.WriteLine(b % a + 2);
        }

    }
}

using System;

namespace Sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split(' ');

            int a = int.Parse(st[0]), b = int.Parse(st[1]);

            if (Math.Min(a, b) * 2 <= Math.Max(a, b))
            {
                Console.WriteLine(Math.Min(a, b));
            }
            else
            {
                Console.WriteLine(Math.Ceiling((double)Math.Max(a, b) / (Math.Min(a, b) * 0.5)));
            }
        }

    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if (n == 0 || m == 0) Console.WriteLine(0);
            else if (n / m <= 0.5) Console.WriteLine(n);
            else if (m / n <= 0.5) Console.WriteLine(m);
            else
            {
                if (m / n <= 0.5) Console.WriteLine(m);
                else
                {
                    int l = (int)(m / 2);
                    n = n - l;
                    m = m - (2 * l);
                    while (n / m >= 2)
                    {
                        l = l + 1;
                        n = n - 2;
                        m = m - 1;
                    }
                    if (m <= 0) Console.WriteLine(l);
                    else Console.WriteLine(l + 1);
                }
            }
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_b_V
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            Int64 n = Convert.ToInt64(s[0]);
            Int64 m = Convert.ToInt64(s[1]);
            int count = 0;
            while((n > 0 && m > 0) || (n > 1 && m > 1))
            {
                if (n >= m)
                {
                    n -= 2;
                    m--;
                    count++;
                }
                else
                {
                    n--;
                    m-= 2;
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_b_V
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            Int64 n = Convert.ToInt64(s[0]);
            Int64 m = Convert.ToInt64(s[1]);
            int count = 0;
            while((n > 0 && m > 0) && (n != 1 && m != 1))
            {
                if (n >= m)
                {
                    n -= 2;
                    m--;
                    count++;
                }
                else
                {
                    n--;
                    m-= 2;
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Linq;

namespace Codeforces
{
    public class Program
    {
        private const int MAXN = 8000;

        public static void Main(string[] args)
        {
            var arr = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = arr[0];
            var m = arr[1];

            var count = 0;
            while (n > 0 && m > 0)
            {
                var max = Math.Max(n, m);
                var min = Math.Min(n, m);

                var groupCount = Math.Min(max / 2, min);
                if (groupCount == 0)
                {
                    break;
                }

                count += groupCount;
                max -= groupCount * 2;
                min -= groupCount;

                n = max;
                m = min;
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    internal class Program
    {

        private static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int ans = 0;

            int op = 0;
            int nov = 0;

            if (n <= 1 || m <= 1) ans = 0;
            else
            {
                if (n == m)
                {
                    ans = 2 * (m / 3);

                    if (m % 3 == 2) ans++;
                }
                else
                {
                    op = n/3;
                    nov = m/3;
                    if (op <= m && nov <= n)
                    {
                        ans = n/3 + m/3;
                        if ((n%3 == 2 && m%3 != 0) || (m%3 == 2 && n%3 != 0)) ans ++;
                    }
                    else
                    {
                        if (n > m)
                        {
                            ans = n / 2;

                            if (m >= op)
                            {
                                ans += op;
                                m -= op;
                                if (m >= 2 && n % 2 == 1) ans++;
                            }
                            else
                            {
                                ans = m % op;
                            }

                        }

                        if (n < m)
                        {
                            nov = m / 2;

                            if (n >= nov)
                            {
                                ans += nov;
                                n -= nov;
                                if (n >= 2 && m % 2 == 1) ans++;
                            }
                            else
                            {
                                ans = n % nov;
                            }

                        }
                    }

                }
            }

            Console.WriteLine(ans);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    internal class Program
    {

        private static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int ans = 0;

            int op = 0;
            int nov = 0;

            if (n <= 1 && m <= 1) ans = 0;
            else
            {
                if (n == m)
                {
                    ans = 2 * (m / 3);

                    if (m % 3 == 2) ans++;
                }
                else
                {
                    op = n/3;
                    nov = m/3;
                    if (op <= m && nov <= n)
                    {
                        ans = n/3 + m/3;
                        if ((n%3 == 2 && m%3 != 0) || (m%3 == 2 && n%3 != 0)) ans ++;
                    }
                    else
                    {
                        if (n > m)
                        {
                            ans = n / 2;

                            if (m >= op)
                            {
                                ans += op;
                                m -= op;
                                if (m >= 2 && n % 2 == 1) ans++;
                            }
                            else
                            {
                                ans = m % op;
                            }

                        }

                        if (n < m)
                        {
                            nov = m / 2;

                            if (n >= nov)
                            {
                                ans += nov;
                                n -= nov;
                                if (n >= 2 && m % 2 == 1) ans++;
                            }
                            else
                            {
                                ans = n % nov;
                            }

                        }
                    }

                }
            }

            Console.WriteLine(ans);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {

        private static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int ans = 0;

            int op = 0;
            int nov = 0;

            if (n <= 1 || m <= 1) ans = 0;
            else
            {
                if (n == m)
                {
                    ans = 2*(m / 3);

                    if (m % 3 == 2) ans++;
                }
                else
                {
                    if (n > m)
                    {
                        op = n / 2;

                        if (m >= op)
                        {
                            ans += op;
                            m -= op;
                            if (m >= 2 && n % 2 == 1) ans++;
                        }
                        else
                        {
                            ans = m % op;
                        }

                    }

                    if (n < m)
                    {
                        nov = m / 2;

                        if (n >= nov)
                        {
                            ans += nov;
                            n -= nov;
                            if (n >= 2 && m % 2 == 1) ans++;
                        }
                        else
                        {
                            ans = n % nov;
                        }

                    }
                }
            }

            Console.WriteLine(ans);
        }

    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {

        private static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int ans = 0;

            int op = 0;
            int nov = 0;

            if (n <= 1 || m <= 1) ans = 0;
            else

            {
                if (n == m)
                {
                    ans = m/2;

                    if (m%2 == 1) ans ++;
                }
                else
                {
                    if (n > m)
                    {
                        op = n/2;

                        if (m >= op)
                        {
                            ans += op;
                            m -= op;
                            if (m >= 2 && n%2 == 1) ans ++;
                        }
                        else
                        {
                            ans = m%op;
                        }

                    }

                    if (n < m)
                    {
                        nov = m/2;

                        if (n >= nov)
                        {
                            ans += nov;
                            n -= nov;
                            if (n >= 2 && m%2 == 1) ans ++;
                        }
                        else
                        {
                            ans = n%nov;
                        }

                    }
                }
            }

            Console.WriteLine(ans);
        }

    }

}

using System;
using System.Collections.Generic;
using System.Text;

namespace CodeTrening
{
    class Program
    {
        static void Main(string[] args)
        {
            string []s = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(s[0]);
            int m = Convert.ToInt32(s[1]);
            int ans = 0;
            while (true)
            {
                if (n == 0) { break; }
                if (m == 0) { break; }
                if (n > m) { ans++; n -= 2; m--; }
                else { ans++; n--; m -= 2; }
            }
            Console.WriteLine(  ans);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace CodeTrening
{
    class Program
    {
        static void Main(string[] args)
        {
            string []s = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(s[0]);
            int m = Convert.ToInt32(s[1]);
            int ans = 0;
            if (n > 1 || m > 1)
            {
                while (true)
                {
                    if (n == 0) { break; }
                    if (m == 0) { break; }
                    if (n > m) { ans++; n -= 2; m--; }
                    else { ans++; n--; m -= 2; }
                }
            }
            Console.WriteLine(  ans);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] l = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            int n = l[0], m = l[1];
            if(n/m>=2 || m/n>=2)
            {
                Console.WriteLine(Math.Min(n, m));
                return;
            }
            int cnt = 0;
            while(n*m>0)
            {
                if(n>m)
                {
                    n -= 2;m--;
                }
                else
                {
                    n--;m -= 2;
                }
                if (n<0||m<0)
                    break;
                cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] l = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            int n = l[0], m = l[1];
            if(n/m>=2 || m/n>=2)
            {
                Console.WriteLine(Math.Min(n, m));
                return;
            }
            int cnt = 0;
            while(n*m>0)
            {
                if(n>m)
                {
                    n -= 2;m--;
                }
                else
                {
                    n--;m -= 2;
                }
                if (n * m <= 0)
                    break;
                cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] l = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            int n = l[0], m = l[1];
            if(n/m>=2 || m/n>=2)
            {
                Console.WriteLine(Math.Min(n, m));
                return;
            }
            int cnt = 0;
            while(n*m>0)
            {
                if(n>m)
                {
                    n -= 2;m--;cnt++;
                }
                else
                {
                    n--;m -= 2;cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}

using System;
 class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                a = int.Parse(input[0]);
                b = int.Parse(input[1]);
            }
            int pairs = 0;
            if(a!=b)
            {
                if(a>b) { int temp = a; a = b; b = temp; }
                if (b - a >= a) { pairs = a; a = b = 0; }
                else { pairs = b - a; a -= pairs; b = a; }
            }
            pairs += a * 2 / 3;
            Console.WriteLine(pairs += a * 2 / 3);
        }
    }

 using System;
 class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                a = int.Parse(input[0]);
                b = int.Parse(input[1]);
            }
            int pairs = 0;
            if(a!=b)
            {
                if(a>b) { int temp = a; a = b; b = temp; }
                if (b - a >= a) { pairs = a; a = b = 0; }
                else { pairs = b - a; a -= pairs; b = a; }
            }
            pairs += a * 2 / 3;
            Console.WriteLine(a%3==2?++pairs:pairs);
        }
    }

using System;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();
            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);
            int ToF = 0;
            for (int i = 0; i<n/2; i++)
            {
                if (k >= n * 2-i*3)
                {
                    Console.WriteLine(n-i);
                    ToF = 1;
                    break;
                }
            }
            if (ToF == 0)
            {
                Console.WriteLine("0");
            }

        }
    }
}

using System;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();
            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);
            for (int i = 0; i<n/2; i++)
            {
                if (k >= n * 2-i*3)
                {
                    Console.WriteLine(n-i);
                    break;
                }
            }

        }
    }
}

using System;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();
            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);
            int ToF = 0;
            if (n >= k * 2)
            {
                Console.WriteLine(k);
            }
            else
            {
                for (int i = 0; i <= n / 2; i++)
                {
                    if (k >= n * 2 - i * 3)
                    {
                        Console.WriteLine(n - i);
                        ToF = 1;
                        break;
                    }
                }
                if (ToF == 0)
                {
                    Console.WriteLine("0");
                }

            }
        }
    }
}

using System;

namespace A_and_B_and_Team_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();
            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);
            int ToF = 0;
            for (int i = 0; i<=n/2; i++)
            {
                if (k >= n * 2-i*3)
                {
                    Console.WriteLine(n-i);
                    ToF = 1;
                    break;
                }
            }
            if (ToF == 0)
            {
                Console.WriteLine("0");
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C.A_and_B_and_Team_Training
{
    class Program
    {
        static int n, m;
        static void Main(string[] args)
        {
            string[] arr = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(arr[0]);
            m = Convert.ToInt32(arr[1]);

                for(int i = n+m; i>2; i--)
                    if(i%3 ==0 ){
                        Console.WriteLine(i/3);
                        return;
                    }
                Console.WriteLine(0);

        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C.A_and_B_and_Team_Training
{
    class Program
    {
        static int n, m;
        static void Main(string[] args)
        {
            string[] arr = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(arr[0]);
            m = Convert.ToInt32(arr[1]);

            if (n == m)
            {
                for(int i = n+m; i>0; i--)
                    if(i%3 ==0 ){
                        Console.WriteLine(i/3);
                        return;
                    }
            }
            int total = m / 2;
            if (total >= n)
            {
                Console.WriteLine(n);
                return;
            }
            if (m % 2 != 0 && n - total > 1)
                Console.WriteLine(total + 1);
            else
                Console.WriteLine(total);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C.A_and_B_and_Team_Training
{
    class Program
    {
        static int n, m;
        static void Main(string[] args)
        {
            string[] arr = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(arr[0]);
            m = Convert.ToInt32(arr[1]);

            int total = m / 2;
            if (total >= n)
            {
                Console.WriteLine(n);
                return;
            }
            if (m % 2 != 0 && n - total > 1)
                Console.WriteLine(total + 1);
            else
                Console.WriteLine(total);
        }

    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if (n == 0 || m == 0) Console.WriteLine(0);
            else if (n / m <= 0.5) Console.WriteLine(n);
            else if (m / n <= 0.5) Console.WriteLine(m);
            else
            {
                if (m / n <= 0.5) Console.WriteLine(m);
                else
                {
                    int l = (int)(m / 2);
                    n = n - l;
                    m = m - (2 * l);
                    while (n / m >= 2)
                    {
                        l = l + 1;
                        n = n - 2;
                        m = m - 1;
                    }
                    if (m < 0) Console.WriteLine(l);
                    else Console.WriteLine(l + 1);
                }
            }
            //Console.ReadKey();
        }
    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if (n == 0 || m == 0) Console.WriteLine(0);
            else
            {
                if (n / m <= 0.5) Console.WriteLine(n);
                else
                {
                    if (m / n <= 0.5) Console.WriteLine(m);
                    else
                    {
                        int l = (int)(m / 2);
                        n = n - l;
                        m = m - (2 * l);
                        while (m / n > 0.5)
                        {
                            l = l + 1;
                            n = n - 1;
                            m = m - 2;
                        }
                        if (m < 0) Console.WriteLine(l - 1);
                        else Console.WriteLine(l + 1);
                    }
                }
            }
            //Console.ReadKey();
        }
    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if(n/m <= 0.5) Console.WriteLine(n);
            else
            {
                int l = (int)(m/2);
                n = n - l;
                m = m - (2 * l);
                while(m/n > 0.5)
                {
                    l = l + 1;
                    n = n - 1;
                    m = m - 2;
                }
                if (m < 0) Console.WriteLine(l-1);
                else Console.WriteLine(l);
            }

            //Console.ReadKey();
        }
    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if (n == 0 || m == 0) Console.WriteLine(0);
            else
            {
                if (n / m <= 0.5) Console.WriteLine(n);
                else
                {
                    int l = (int)(m / 2);
                    n = n - l;
                    m = m - (2 * l);
                    while (m / n > 0.5)
                    {
                        l = l + 1;
                        n = n - 1;
                        m = m - 2;
                    }
                    if (m < 0) Console.WriteLine(l - 1);
                    else Console.WriteLine(l + 1);
                }
            }
            //Console.ReadKey();
        }
    }
}

using System;

namespace _519C___Codeforces
{
    class Program
    {
        static void Main()
        {
            string[] nums = Console.ReadLine().Split();
            double n = double.Parse(nums[0]);
            double m = double.Parse(nums[1]);

            if(n/m <= 0.5) Console.WriteLine(n);
            else
            {
                int l = (int)(m/2);
                n = n - l;
                m = m - (2 * l);
                while(m/n > 0.5)
                {
                    l = l + 1;
                    n = n - 1;
                    m = m - 2;
                }
                if (m < 0) Console.WriteLine(l-1);
                else Console.WriteLine(l+1);
            }

            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        private static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]),
                m = int.Parse(s[1]),
                answer = 0;

            while (n >= 1 && m >= 2 || n >= 2 && m >= 1)
            {
                if (n >= 1 && m >= 2)
                {
                    n--;
                    m -= 2;
                }
                else
                {
                    m--;
                    n -= 2;
                }
                answer++;
            }
            Console.WriteLine(answer);
        }
    }
}

using System;
using System.Collections.Generic;

public class Program
{
    static int Count(int n, int m)
    {
        if(n + m < 3)
        {
            return 0;
        }

        if(n == m && n%2 == 0)
        {
            return (n + m)/3;
        }

        var min = 0;
        var max = 0;

        if(n > m)
        {
            max = n;
            min = m;
        }
        else
        {
            max = m;
            min = n;
        }

        var pairs = max/2;

        if(min <= pairs)
        {
            return min;
        }
        else
        {
            return pairs + Count(min - pairs, max - pairs*2);
        }
    }

    static void Main()
    {
        var args = Console.ReadLine().Split(' ');
        var n = int.Parse(args[0]);
        var m = int.Parse(args[1]);

        if(n + m < 3)
        {
            Console.WriteLine(0);
        }
        else
        {
        Console.WriteLine(Count(n,m));
        }
    }
}

using System;
using System.Collections.Generic;

public class Program
{
    static void Main()
    {
        var args = Console.ReadLine().Split(' ');

        Console.WriteLine((int.Parse(args[0]) + int.Parse(args[1]))/3);
    }
}

using System;
using System.Collections.Generic;

public class Program
{
    static int Count(int n, int m)
    {
        var min = 0;
        var max = 0;

        if(n > m)
        {
            max = n;
            min = m;
        }
        else
        {
            max = m;
            min = n;
        }

        var pairs = max/2;

        if(min <= pairs)
        {
            return min;
        }
        else
        {
            return pairs + Count(min - pairs, max - pairs*2);
 }
    }

    static void Main()
    {
        var args = Console.ReadLine().Split(' ');
        var n = int.Parse(args[0]);
        var m = int.Parse(args[1]);

        if(n + m < 3)
        {
            Console.WriteLine(0);
        }
        else
        {
        Console.WriteLine(Count(n,m));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]), ans = 0;
            for (int t1 = 0; t1 <= n / 2; t1++) {
                int t2 = Math.Min(n - 2 * t1, (n - t1) / 2);
                if (t1 + t2 > ans)
                    ans = t1 + t2;
            }
            Console.Write(ans);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]), ans = 0;
            for (int t1 = 0; t1 <= n / 2; t1++) {
                int t2 = Math.Min(n - 2 * t1, (m - t1) / 2);
                if (t1 + t2 > ans)
                    ans = t1 + t2;
            }
            Console.Write(ans);
            // Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]), ans = 0;
            for (int t1 = 0; t1 <= n / 2; t1++) {
                int t2 = Math.Min(n - 2 * t1, (m - t1) / 2);
                if (t1 >= 0 && t2 >= 0 && t1 + t2 > ans)
                    ans = t1 + t2;
            }
            Console.Write(ans);
            // Console.ReadKey();
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace CodeForces.PRACTICE
{
    // A and B and Team Training (greedy, implementation, math, number theory)
    class _519C
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[0]);
            if (m >= 2 * n) Console.WriteLine(n);
            else if (n >= 2 * m) Console.WriteLine(m);
            else Console.WriteLine((n + m) / 3);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;
using System.Text.RegularExpressions;

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
#if  LOCAL_TEST
        private readonly TextReader inputStream = new StreamReader("input.txt");
#else
        private readonly TextReader inputStream = Console.In;
#endif
#if  FBHC_TEST
        private readonly TextWriter outputStream = new StreamWriter("output.txt");
#else
        private readonly TextWriter outputStream = Console.Out;
#endif

        private string[] tokens;
        private int pointer;

        public char NextChar()
        {
            try
            {
                var c = inputStream.Read();

                if (c < 0)
                    c = 0;

                return (char)c;
            }
            catch (IOException)
            {
                return '\0';
            }
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            var res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

        public IEnumerable<T> NextSeq<T>(long n)
        {
            for (var i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            var ienum = o as IEnumerable;

            if (ienum != null && typeof(T) != typeof(string))
            {
                var first = true;

                foreach (var iev in ienum)
                {
                    if (!first && iev != null)
                        Print(" ");

                    Print(iev);

                    first = false;
                }

            }
            else
            {
                outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
            }

        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static string Reverse(this string s)
        {
            var charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static long MODPower(this int x, long y, long mod)
        {
            long answ = 1;

            if (y == 0)
                return answ;
            if (y % 2 == 1)
                answ *= x;

            answ *= MODPower(x, y / 2, mod) * MODPower(x, y / 2, mod);

            answ %= mod;

            return answ;
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<int, IList<T>, T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval(i, self);

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<int, T> fval)
        {
            return self.Fill((x, slf) => fval(x));
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            return self.Fill(x => fval());
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }

        public static int Xor1n(this int n)
        {
            return (n >> 1) & 1 ^ ((n & 1) > 0 ? 1 : n);
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = unchecked(hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode()));
            hash = unchecked(hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode()));
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (var io = new MyIo())
            {
                try
                {
                    new Program(io)
                        .Solve();
                }
                catch (Exception e)
                {
                    io.PrintLine(e.Message + "\r\n" + e.StackTrace);

                    throw;
                }
            }
        }

        #endregion

        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {

            int n = io.NextInt();
            int m = io.NextInt();
            int x = 0;
            int dx = 0;

            do
            {
                if (m > n)
                {
                    int tmp = m;
                    m = n;
                    n = tmp;
                }
                dx = Math.Min(n/2, m);
                x += dx;
                n -= dx*2;
                m -= dx;

            } while (dx > 0);

            io.Print(x);

        }

    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Round_294
{
    class Program
    {
        static void Main(string[] args)
        {

            //Chess ch = new Chess();
            //ch.Test();
            //CompilationErrors ce = new CompilationErrors();
            //ce.Test();
            TeamTraining tt = new TeamTraining();
            tt.Test();
        }
    }
    class Chess
    {

        void Count(string[] board,out long  cntb,out long cntw)
        {
            cntb=0;
            cntw=0;
            for(int i=0;i<board.Length;i++)
                for(int j=0;j<board[i].Length;j++)
                {
                    switch(board[i][j])
                    {
                        case 'Q':cntw+=9;break;
                        case 'R': cntw+=5;break;
                        case 'B': cntw+=3;break;
                        case 'N':cntw+=3;break;
                        case 'P':cntw+=1;break;

                        case 'q':cntb+=9;break;
                        case 'r': cntb+=5;break;
                        case 'b': cntb+=3;break;
                        case 'n':cntb+=3;break;
                        case 'p':cntb+=1;break;

                        default:break;
                    }
                }
        }
        public void Test()
        {
            string[]board =new string[8];
            for(int i=0;i<board.Length;i++)
                board[i]=Console.ReadLine();
            long cntb=0;
            long cntw=0;
            Count(board,out cntb,out cntw);
            if(cntb>cntw)Console.WriteLine("Black");
            else if(cntb<cntw)Console.WriteLine("White");
            else Console.WriteLine( "Draw");
        }
    }
    class CompilationErrors
    {
        public void Test()
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = new long[n];
            string[] ss=Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(ss[i]);
            long []b=new long[n-1];
            ss = Console.ReadLine().Split();
            for (int i = 0; i < n-1; i++)
                b[i] = int.Parse(ss[i]);
            long[] c = new long[n - 2];
            ss = Console.ReadLine().Split();
            for (int i = 0; i < n-2; i++)
                c[i] = int.Parse(ss[i]);
            Console.WriteLine(Cmp(a, b));
            Console.WriteLine(Cmp(b,c));
        }
        long Cmp(long []a,long[]b)
        {
            long x = 0;
            for (int i = 0; i < a.Length; i++)
                x = x ^ a[i];
            for (int i = 0; i < b.Length; i++)
                x = x ^ b[i];
            return x;
        }
    }
    class TeamTraining
    {
        public void Test()
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            //long max=0;
            //long cnt =0;
            //for(int i=1;i<=n;i++)
            //{
            //    cnt = i + Min(m - 2 * i, n - i);
            //    if (cnt > max) max = cnt;
            //}
            //Console.WriteLine(max);
            long cnt = 0;
            if(n<2&&m<2)
            {
                Console.WriteLine("0");
                return;
            }
            while(n>0&&m>0)
            {
                if (n > m) n--;
                else m--;
                n--;
                m--;
                cnt++;
            }
            Console.WriteLine(cnt);
        }
        int Min(int a,int b)
        {
            return a < b ? a : b;
        }
    }

}

using System;
namespace Contest
{
class MainClass{
   public static void Main (string[] args){
            long n,s=0,k,ss=0;
            string[] st=Console.ReadLine().Split(' ');
            n=long.Parse(st[0]);
            k=long.Parse(st[1]);

            if(n<k)
            {
                long p=k;
                k=n;
                n=p;
            }
            ss=k-n/2;
            if(ss<0)
            {
                s+=k;
            }
            else
            {
                s+=n/2;
                k-=n/2;
                n=n%2;

                ss=n-k/2;
                if(ss<0)
                {
                    s+=n;
                }
                else
                    {
                        s+=k/2;
                    }
            }

              Console.WriteLine(s);
    }
}
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prC {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            int n = Next();
            int m = Next();
            int a = 0;
            while(n != 0 && m != 0) {
                if(n > m) {
                    n -= 2;
                    m--;
                }
                else {
                    n--;
                    m -= 2;
                }
                a++;
            }
            writer.WriteLine(a);

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];

            int t1 = 0; // N M M
            int t2 = 0; // N N M
            if (m < n)
            {
                int t = n;
                n = m;
                m = t;
            }

            t1 += Math.Min(m / 2, n);
            n -= t1;
            m -= t1 * 2;
            t2 += Math.Min(n / 2, m);

            Console.WriteLine(t1 + t2);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];

            int T = 0;

            int t = Math.Min(m / 3, n / 3);
            T += t * 2;

            m -= t * 3;
            n -= t * 3;

            if (m < n)
            {
                t = m;
                m = n;
                n = t;
            }

            T += Math.Min(m / 2, n);

            Console.WriteLine(T);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];

            int T = 0;

            if (m >= n * 2)
            {
                T += n;
            }
            else if (n >= m * 2)
            {
                T += m;
            }
            else
            {
                int t = Math.Min(m / 3, n / 3);
                T += t * 2;

                m -= t * 3;
                n -= t * 3;

                if (m < n)
                {
                    t = m;
                    m = n;
                    n = t;
                }

                T += Math.Min(m / 2, n);
            }

            Console.WriteLine(T);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c)
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string GetString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var a = getList();
			var n = a[0];
			var m = a[1];
			var ans = 0;
			if (n > m)
			{
				var q = n;
				n = m;
				m = q;
			}
			var p = Min(n, m / 2);
			ans += p;
			n -= p;
			m -= p * 2;
			if (n != 0 && m != 0)
			{
				p = Min(m, n / 2);
				ans += p;
			}
			Console.WriteLine(ans);
			/*			input.Close();
			output.Close();*/
		}
	}
}

using System;
using System.Linq;

namespace _519C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var O = s[0]; var H = s[1];
            int count = 0;
            while (O>0 && H>0)
            {
                count++;
                if (O > H) { O-=2;H--;}
                else { O--; H -= 2; }
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split((char)32), int.Parse);
            int firstMethod = 0;
            int secondMethod = 0;

            methodOne(input[0], input[1], ref firstMethod);
            methodSecond(input[0], input[1], ref secondMethod);

            if (firstMethod > secondMethod)
            {
                Console.WriteLine(firstMethod.ToString());
            }
            else
            {
                Console.WriteLine(secondMethod.ToString());
            }
        }

        static void methodOne(int expertNum, int newbieNum, ref int teamNum)
        {
            int trackCount = 0;

            while ((expertNum - 1) >= 0 && (newbieNum - 2) >= 0)
            {
                teamNum++;
                trackCount++;

                expertNum--;
                newbieNum -= 2;
            }

            if (trackCount == 0)
            {
                return;
            }

            methodSecond(expertNum, newbieNum, ref teamNum);
        }

        static void methodSecond(int expertNum, int newbieNum, ref int teamNum)
        {
            int trackCount = 0;

            while ((expertNum - 2) >= 0 && (newbieNum - 1) >= 0)
            {
                teamNum++;
                trackCount++;

                expertNum -= 2;
                newbieNum--;
            }

            if (trackCount == 0)
            {
                return;
            }

            methodOne(expertNum, newbieNum, ref teamNum);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split((char)32), int.Parse);
            int[] temp = new int[2] { input[0], input[1] };
            int firstMethod = 0;
            int secondMethod = 0;
            int thirdMethod = 0;

            methodOne(ref input[0], ref input[1], ref firstMethod);

            Array.Copy(temp, input, temp.Length);
            methodSecond(ref input[0], ref input[1], ref secondMethod);

            Array.Copy(temp, input, temp.Length);

            methodThird(ref input[0], ref input[1], ref thirdMethod);

            Array.Copy(temp, input, temp.Length);

            int[] resultArray = new int[3] { firstMethod, secondMethod, thirdMethod };

            Console.WriteLine(resultArray.Max());
        }

        static void methodOne(ref int expertNum, ref int newbieNum, ref int teamNum)
        {
            int trackCount = 0;

            while ((expertNum - 1) >= 0 && (newbieNum - 2) >= 0)
            {
                teamNum++;
                trackCount++;

                expertNum--;
                newbieNum -= 2;
            }

            if (trackCount == 0)
            {
                return;
            }

            methodSecond(ref expertNum, ref newbieNum, ref teamNum);
        }

        static void methodSecond(ref int expertNum, ref int newbieNum, ref int teamNum)
        {
            int trackCount = 0;

            while ((expertNum - 2) >= 0 && (newbieNum - 1) >= 0)
            {
                teamNum++;
                trackCount++;

                expertNum -= 2;
                newbieNum--;
            }

            if (trackCount == 0)
            {
                return;
            }

            methodOne(ref expertNum, ref newbieNum, ref teamNum);
        }

        static void methodThird(ref int expertNum, ref int newbieNum, ref int teamNum)
        {
            int trackCount = 0;

            while ((expertNum - 3) >= 0 && (newbieNum - 3) >= 0)
            {
                teamNum += 2;
                trackCount += 2;

                expertNum -= 3;
                newbieNum -= 3;
            }

            if (trackCount == 0)
            {
                return;
            }

            methodOne(ref expertNum, ref newbieNum, ref teamNum);
            methodSecond(ref expertNum, ref newbieNum, ref teamNum);
        }
    }
}