Fortunately, you are hired and now you are a teaching assistant in Baldi's math class. Your first job is to calculate the score for every student in the class. The score will be evaluated by the students' midterm, final exam, and homework. Baldi came up with three ways for the student to determine their score:
formula A: 0.7 * average(mid, final) + 0.3 * hw
formula B: 0.5 * max(mid, final) + 0.3 * min(mid, final) + 0.2 * hw
formula C: 0.8 * average(mid, final) + 0.1 * hw + 10
Now the students have decided the ways they want to determine their scores. Calculate the result for them.
Baldi would be very angry if you get the answer wrong. He punishes every single person who makes mistakes in math problems.
A single line contains three integers S1, S2, S3, and a char P, which means a student got S1 for the homework, got S2 on the midterm, got S3 on the final exam, and choose formula P to determine the score.
Constraints:
0 ≤ S1, S2, S3 ≤ 100
P ∈ {'A', 'B', 'C'}
Output the student's score, which is a floating point rounded to 2nd decimal places.
Please remember to print '\n' at the end.