cho.sh
Notes
Loading...

Dice Sum

Time limit

2s

Memory limit

128 MB

Problem

Three special dice are rolled at the same time. The first die has faces numbered from 1 to S1, the second die has faces numbered from 1 to S2, and the third die has faces numbered from 1 to S3.

For every possible triple of rolled values (a, b, c), count how often each sum a + b + c appears. Print the sum that appears most often. If several sums appear equally often, print the smallest such sum.

Input

The first line contains three integers S1, S2, and S3, separated by spaces.

  • 2 <= S1 <= 20
  • 2 <= S2 <= 20
  • 2 <= S3 <= 40

Output

Print the most frequent sum of the three dice. If there is more than one answer, print the smallest sum among them.