跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1744. A and B and Team Training

    ID: 1750 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>贪心模拟数学数论算法思想编程与模拟基础难度共享题库Codeforces英文题面题目来源题面语言

A and B and Team Training

题目描述

C. A and B and Team Training
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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·105) − 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.

Examples
Input
2 6
Output
2
Input
4 5
Output
3
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).


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1292 题。保留原作者与原赛事署名。