cho.sh
Notes
Loading...

Date Cycle Calculation

Time limit

2s

Memory limit

4 MB

Problem

In Jun-gyu's country, years are represented differently from the calendar we usually use. A year in this country is written as three numbers, E, S, and M, representing the cycles of Earth, Sun, and Moon.

Each number has its own range.

  • 1 <= E <= 15
  • 1 <= S <= 28
  • 1 <= M <= 19

Year 1 in our calendar is written as 1 1 1 in this system. Every year, all three numbers increase by 1. If a number passes the end of its range, it becomes 1 again.

So year 15 is written as 15 15 15, but the next year, year 16, is written as 1 16 16 because E cannot exceed 15.

Given E, S, and M, determine which year in our calendar is represented by those three numbers. Print the earliest possible year.

Input

The first line contains three integers E, S, and M, separated by spaces. The input always satisfies the ranges above.

Output

Print the earliest year represented by E S M. Since 1 1 1 is always year 1, the answer is always positive.