Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only one pipe with flowing water. Besides, Vova has several splitters.

A splitter is a construction that consists of one input (it can be connected to a water pipe) and *x* output pipes. When a splitter is connected to a water pipe, water flows from each output pipe. You can assume that the output pipes are ordinary pipes. For example, you can connect water supply to such pipe if there's water flowing out from it. At most one splitter can be connected to any water pipe.

Vova has one splitter of each kind: with 2, 3, 4, ..., *k* outputs. Help Vova use the minimum number of splitters to build the required pipeline or otherwise state that it's impossible.

Vova needs the pipeline to have exactly *n* pipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.
The first line contains two space-separated integers *n* and *k* (1 ≤ *n* ≤ 10<sup class="upper-index">18</sup>, 2 ≤ *k* ≤ 10<sup class="upper-index">9</sup>).

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
import bisect
def power(b,p):
    c=1
    while p!=0:
        if p%2==0:
            b=((b%(pow(10,9)+7))*(b%(pow(10,9)+7)))%(pow(10,9)+7)
            p=p//2
        else:
            c=((c%(pow(10,9)+7))*(b%(pow(10,9)+7)))%(pow(10,9)+7)
            p=p-1
    return c
def chef(k):
    cnum=k
    retnum=0
    if k<10:
        return k
    elif k>=10:
        k=k//10
        while k!=0:
            cnum=cnum*10+k%10
            k=k//10
        return cnum
    return retnum
def pairs(x,y):
    if x[0]<y[0]:
        return False
    elif x[0]>y[0]:
        return True
    return x[1]<y[1]
def sort(a,n):
    for i in range(n-1):
        if a[i]>a[i]+1:
            return True
    return False
def posible(cur,n,k):
    powd=0
    for i in range(n):
        x=a[i]*cur
        if x>b[i]:
            powd+=x-b[i]
        if powd>k:
            return 0
    return 1
def bs(l,r):
    while l<r:
        m=(l+r)//2
        if posible(m,n,k):
            l=m+1
        else:
            r=m-1
    if posible(l,n,k):
        return l
    else:
        return l-1

def main():

        n, k= map(int, input().split())
        initial=1
        splitter=0
        while initial<n:
            added=min(n-initial,k-1)
            if added<=0:
                print(-1)
                break
            initial+=added
            splitter+=1
        if initial>=n:
            print(splitter)




# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()