Choosing subjects
Time limit2sMemory limit512 MB
Pick the three highest scores among the four science subjects and the higher of history and geography, then print their sum.
Problem
JOI sat exams in six subjects: physics, chemistry, biology, earth science, history and geography. Each exam is worth at most 100 points.
JOI picks three subjects out of physics, chemistry, biology and earth science, and one subject out of history and geography.
Find the total score of the picked subjects when the picks are made so that the total is as large as possible.
Input
The input has six lines, each holding one integer.
The first line holds the physics score .
The second line holds the chemistry score .
The third line holds the biology score .
The fourth line holds the earth science score .
The fifth line holds the history score .
The sixth line holds the geography score .
Every one of , , , , and is an integer between and , inclusive.
Output
Print the total score of the four subjects JOI picked on one line.
Hint
In the first example the total is largest when JOI picks physics, biology, earth science and history. Those four scores are 100, 76, 42 and 10, so the total is 228.
In the second example the total is largest when JOI picks chemistry, biology, earth science and geography. Those four scores are 21, 15, 42 and 62, so the total is 140.