A and B and Team Training

题意翻译

## 题目描述 A和B正在准备编程比赛。 准备比赛中十分重要的一环即是让编程老手们向新手们传授经验。所以,在下一次团队训练中,A决定将成员分组,使新手和老手一起面对和解决问题。 A认为一个合理的分组由一个老手和两个新手构成。这样,老手们就可以向尽可能多的人传授他们的知识。 B认为一个合理的分组由两个老手和一个新手构成。这样,新手们就可以增长见识,更多地提升能力。 于是,A和B经过商议决定,每一个分组都必须是以上两种分组的一种,同时分出的组要尽量多。 现在我们知道一共有$n$ 位编程老手,$m$ 位新手,那么最多可以分成多少组呢? ## 输入输出格式 ### 输入格式 一行,输入编程老手数量$n$ ,新手数量$m$ ,中间含空格$$(0<=n,m<=500000)$$ ### 输出格式 一行,表示最多的分组数。 ## 说明 只作注释:XP为老手,NB为新手。 感谢@lonelysir 提供的翻译

题目描述

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·10^{5} $ ) — the number of experienced participants and newbies that are present at the training session.

输出格式


Print the maximum number of teams that can be formed.

输入输出样例

输入样例 #1

2 6

输出样例 #1

2

输入样例 #2

4 5

输出样例 #2

3

说明

Let'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).