Codeforces Round 294 (Div. 2)
C
A and B and Team Training
Codeforces
1300
原题
← BD →
翻译中…

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?

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

Print the maximum number of teams that can be formed.

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #1
2 6
Output #1
2
InputCopy OutputCopy
Input #2
4 5
Output #2
3
InputCopy OutputCopy
题目信息
题号
519C
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。