Under construction

Still being built. Things may change

Map

Time limit2sMemory limit1024 MB

Summary
Given n scraps and k parts per tear, find how many seconds t Vasya tore the map, or print -1 if no such t exists.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

The hooligan Vasya got an F in geography and, out of anger, started tearing up a map. He did this for tt seconds.

Every second he took any piece of the map and tore it into kk parts. When he finished, he found nn scraps in front of him.

While he was destroying the map, he lost track of time. Now he wants to know how long he tore the map, so he asked you to find tt.

Input

The first line contains two integers nn and kk (1≤n,k≤1091 \le n, k \le 10^9).

Output

If no suitable tt exists, print a single number −1-1. Otherwise, print tt.

Examples2

  1. Example 1

    Input
    10 4
    
    Expected output
    3
    
  2. Example 2

    Input
    10 3
    
    Expected output
    -1