题目描述
Problem Description
Takahashi is participating in a contest consisting of two problems, which lasts for $T$ minutes.
The first problem can be solved in exactly $A$ minutes, and solving it adds $B$ points to the score.
The second problem can be solved in exactly $C$ minutes, and solving it adds $D$ points to the score.
The second problem is more difficult than the first, so the points are $B \leq D$, but you can solve them in any order.
The contest allows starting the next problem immediately after the previous one is finished, and finishing a problem at the same time as the contest ends is also permitted.
What is the maximum score Takahashi can achieve?
Input Format
The input is given from the standard input in the following format:
$T$ $A$ $B$ $C$ $D$
Output Format
Output the maximum score Takahashi can achieve.
Sample Input and Output
Sample Input #1
100 20 500 40 1000
Sample Output #1
1500
Sample Input #2
50 100 1500 100 1500
Sample Output #2
0
Sample Input #3
100 100 1000 100 1000
Sample Output #3
1000
Notes/Hints
Constraints
- $1 \leq T, A, B, C, D \leq 10^9$
- All inputs are integers.
Sample Explanation 1
Both problems can be solved within the time limit.
Sample Explanation 2
If neither problem can be solved, the score is $0$ points.
Sample Explanation 3
Solving either problem results in the same score.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分