PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000184. Đội hoàn hảo (Perfect Team)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đội hoàn hảo (Perfect Team)

Perfect Team

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A perfect programming team has exactly three members, including at least one coder and at least one mathematician. There are cc students who specialize only in coding, mm who specialize only in mathematics, and xx with neither specialization. Nobody has both specializations, and each student may join at most one team. A team may contain more than one student of a specialization as long as it meets the requirements. Find the maximum number of perfect teams.

Input

The only line contains three nonnegative integers cc, mm, and xx: the numbers of coders, mathematicians, and students without either specialization.

Output

Print one integer: the maximum number of perfect teams that can be formed.

Subtasks

  • Subtask 1 (20 points): 0≤c,m,x≤300\le c,m,x\le 30.
  • Subtask 2 (30 points): 0≤c,m,x≤1000000\le c,m,x\le 100000.
  • Subtask 3 (50 points): 0≤c,m,x≤1000000000\le c,m,x\le 100000000.

Examples

Example 1

Input

4 4 1

Output

3

Explanation

There are four coders, four mathematicians, and one unskilled student. Form one team of one from each group, one team of two coders and one mathematician, and one team of one coder and two mathematicians. All nine students make three valid teams. As each team has three members, more than 9/3=39/3=3 teams are impossible.

Example 2

Input

10 1 10

Output

1

Explanation

Only one student specializes in mathematics. Every team needs a mathematician, so at most one team can be formed. Selecting one student from each group achieves one valid team.