cho.sh
Notes
Loading...

Banknotes for a New Game

Time limit

2s

Memory limit

128 MB

Problem

A game uses banknotes as its currency. The set of banknote denominations must satisfy the following conditions.

  1. There are exactly K distinct denominations.
  2. The smallest denomination is 1 won.
  3. For each i, the i-th denomination is 2, 3, 4, or 5 times the (i-1)-th denomination.

A player receives N won at the start of the game. For the same amount of money, using fewer banknotes is better. You may choose any denomination set satisfying the conditions. Find the minimum number of banknotes needed to make exactly N won.

Input

The input contains two integers N and K.

Output

Print the minimum number of banknotes needed to make N won.

Constraints

  • 1 ≤ N ≤ 10^18
  • 1 ≤ K ≤ 100