An alien civilization has advanced to the point where it needs to start keeping track of time. Its leaders have therefore decided to design a calendar. Like many Earthly calendars, this calendar is going to be based on the motion of celestial bodies: in particular the calendar must include period of rotation of their planet (a day) and the period of orbit of the planet around the sun (a real year). Unfortunately, just as is the case on Earth, a real year is not necessarily a convenient integer number of days. Their solution to this problem is to define a calendar year, which is an integer number of days long, and periodically insert an extra day into some calendar years (leap years) in order to correct the discrepancy and resychronize the start of the calendar year with the start of the real year.
The formal requirements for the calendar are as follows:
- A normal calendar year is a length of time that is some integer number N days long.
- A leap calendar year is exactly one day longer than a normal calendar year (N+1 days long).
- Each calendar year is either a normal year or a leap year.
- The calendar must have some positive integer period P, such that every P whole consecutive calendar years sum to exactly the same length of time as P real years.
The leaders wish to design the calendar to make the period P as short as possible. A day is dayLength time units long and a real year is yearLength time units long. Return the smallest achievable positive integer value of P.