Under construction

Still being built. Things may change

Missed Call

Interview

Time limit2sMemory limit128 MB

Summary
Simulate an album of N songs with 5-second gaps and a phone ringing every D seconds to find the first ring Kangto can actually hear.
Level

Easy3 of 10

Topics
Simulation, Implementation, Math
Solved
No attempts yet

Problem

A new album by Day Of Mourning 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.

Examples3

  1. Example 1

    Input
    2 5 7
    
    Expected output
    7
    
  2. Example 2

    Input
    4 5 20
    
    Expected output
    40
    
  3. Example 3

    Input
    6 9 20
    
    Expected output
    40