CF241A Old Peykan

Description

There are $ n $ cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as $ c_{1},c_{2},...,c_{n} $ . The Old Peykan wants to travel from city $ c_{1} $ to $ c_{n} $ using roads. There are $ (n-1) $ one way roads, the $ i $ -th road goes from city $ c_{i} $ to city $ c_{i+1} $ and is $ d_{i} $ kilometers long. The Old Peykan travels 1 kilometer in 1 hour and consumes 1 liter of fuel during this time. Each city $ c_{i} $ (except for the last city $ c_{n} $ ) has a supply of $ s_{i} $ liters of fuel which immediately transfers to the Old Peykan if it passes the city or stays in it. This supply refreshes instantly $ k $ hours after it transfers. The Old Peykan can stay in a city for a while and fill its fuel tank many times. Initially (at time zero) the Old Peykan is at city $ c_{1} $ and $ s_{1} $ liters of fuel is transferred to it's empty tank from $ c_{1} $ 's supply. The Old Peykan's fuel tank capacity is unlimited. Old Peykan can not continue its travel if its tank is emptied strictly between two cities. Find the minimum time the Old Peykan needs to reach city $ c_{n} $ .

Input Format

The first line of the input contains two space-separated integers $ m $ and $ k $ $ (1

Output Format

In the only line of the output print a single integer — the minimum time required for The Old Peykan to reach city $ c_{n} $ from city $ c_{1} $ .

Explanation/Hint

In the second sample above, the Old Peykan stays in $ c_{1} $ for 3 hours.