Under construction

Still being built. Things may change

Dice Sum

Interview

Time limit2sMemory limit128 MB

Summary
Given three dice with sizes S1, S2, S3, find the sum value that occurs most often among all possible triples, choosing the smallest if tied.
Level

Easy3 of 10

Topics
Brute force, Math, Simulation
Solved
No attempts yet

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.

Examples1

  1. Example 1

    Input
    3 2 3
    
    Expected output
    5