CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Rabbits
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Far far away in the future, humanity has sent 1 frozen newborn rabbit pair to populate an alien planet. Each pair of rabbits reaches maturity at the age of 1 month and they immediately mate. One month after mating the pair reproduces one pair of rabbits, after which the older pair mates again immediately. The rabbits never die and continue breeding forever.

How many months will the rabbit population be in an interval between a and b?

Input:

The first line contains 2 integers a,\,b: the interval boundaries.

Output:

Print a single integer d: the duration (in months) when the number of rabbit pairs is in the interval [a,\,b] inclusive.

Constraints:

1 \leq a \leq b \leq 10^{100}

Example:

Input:

3 5

Output:

2

Explanation:

During 1^{st} month: 1 pair of newborn rabbits. No mating.

During 2^{nd} month: still 1 pair of rabbits, 1 pair mates at the beginning of the month and at the end of the month you'll have 1 new pair of newborns.

During 3^{rd} month: now there are 2 pairs of rabbits. The older pair mates at the beginning of the month and at the end of the month you'll have 1 new pair of newborns.

During 4^{th} month: 3 pairs of rabbits, 2 of which mate. At the end of the 4^{th} month you'll have 2 new pairs of newborns.

During 5^{th} month: 5 pairs of rabbits, 3 of which mate. At the end of the 4^{th} month you'll have 3 new pairs of newborns.