cho.sh
Notes
Loading...

Missed Call

Time limit

2s

Memory limit

128 MB

Problem

A new album by has just been released. Kangto wants to listen to the whole album exactly once from the beginning.

The album contains N songs, and every song lasts L seconds. Between two adjacent songs there is a 5-second quiet interval when no song is playing.

Let time 0 be the moment Kangto starts listening to the first song. His phone also starts ringing at time 0, and then rings once every D seconds. Each ring lasts for 1 second.

Because Kangto listens at a very high volume, he cannot hear the ringtone while a song is playing. If a ring starts exactly when a song starts, he cannot hear it. If a ring ends exactly when a song ends, he also cannot hear it.

After all songs in the album have finished, Kangto can hear the ringtone.

Find the earliest time when Kangto can hear his phone ring.

Input

The first line contains three integers N, L, and D, separated by spaces.

Output

Print the earliest time when Kangto can hear the ringtone.

Constraints

  • 1 ≤ N ≤ 20
  • 1 ≤ L ≤ 180
  • 1 ≤ D ≤ 20

Hint

There is no additional hint.