Under construction

Still being built. Things may change

The Devil's Offer

Time limit1sMemory limit512 MB

Summary
Given K and N, find the smallest integer X such that after paying K and multiplying the rest by N, the result is at least X, or report -1 if no such X exists.
Level

Medium6 of 10

Topics
Math, Binary search, Number theory, Implementation
Solved
No attempts yet

Problem

One day, Minju met a devil in a dream. The devil says that if she pays him K won, he will multiply the amount left after the payment by N.

Minju wants to know the minimum amount of money she must have so that she does not lose money when she pays the devil K won.

Given the K and N the devil proposes, find the minimum amount X that Minju must have in order not to lose money. The amount must be an integer.

Input

The first line gives the integers K and N proposed by the devil, separated by a space. (1 ≤ K, N ≤ 200,000,000)

Output

Print the minimum amount X that Minju must have in order not to lose money.

If Minju always loses money, print -1.

Examples2

  1. Example 1

    Input
    24 2
    
    Expected output
    48
    
  2. Example 2

    Input
    36 3
    
    Expected output
    54