JOIN

 Problem Statement

Problem Statement for ProblemSets

### Problem Statement

Cat Snuke came up with some problems. He wants to construct as many problem sets as possible using those problems. Each problem set must contain exactly three problems: one for the Easy slot, one for the Medium slot, and one for the Hard slot. Each problem can only be assigned to a single slot in a single problem set. He came up with E + EM + M + MH + H problems in total. The distribution of the problems is as follows:
• E problems can only be used in the Easy slot.
• EM problems can be used either in the Easy slot or the Medium slot.
• M problems can only be used in the Medium slot.
• MH problems can be used either in the Medium slot or the Hard slot.
• H problems can only be used in the Hard slot.
Return the maximal number of problem sets he can construct.

### Definition

 Class: ProblemSets Method: maxSets Parameters: long, long, long, long, long Returns: long Method signature: long maxSets(long E, long EM, long M, long MH, long H) (be sure your method is public)

### Constraints

-E, EM, M, MH, H will be between 0 and 1,000,000,000,000,000,000 (10^18), inclusive.

### Examples

0)

 `2` `2` `1` `2` `2`
`Returns: 3`
 One of EM problems should be used for the Easy slot, and the other should be used for the Medium slot. One of MH problems should be used for the Medium slot, and the other should be used for the Hard slot.
1)

 `100` `100` `100` `0` `0`
`Returns: 0`
 Unfortunately, no problem can be used for the Hard slot.
2)

 `657` `657` `657` `657` `657`
`Returns: 1095`
3)

 `1` `2` `3` `4` `5`
`Returns: 3`
4)

 `1000000000000000000` `1000000000000000000` `1000000000000000000` `1000000000000000000` `1000000000000000000`
`Returns: 1666666666666666666`

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
Single Round Match 657 Round 1 - Division I, Level One