Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m. 

What is the minimal number of moves making him climb to the top of the stairs that satisfies his condition?


-----Input-----

The single line contains two space separated integers n, m (0 < n ≤ 10000, 1 < m ≤ 10).


-----Output-----

Print a single integer — the minimal number of moves being a multiple of m. If there is no way he can climb satisfying condition print  - 1 instead.


-----Examples-----
Input
10 2

Output
6

Input
3 5

Output
-1



-----Note-----

For the first sample, Dreamoon could climb in 6 moves with following sequence of steps: {2, 2, 2, 2, 1, 1}.

For the second sample, there are only three valid sequence of steps {2, 1}, {1, 2}, {1, 1, 1} with 2, 2, and 3 steps respectively. All these numbers are not multiples of 5.

Difficulty: interview

Starter code:

Solutions:
# 272 D2 A

def func(p,m,n):
    w = p
    while w % m != 0 and w<=n:
        w += 1
    if w<= n:
        return w
    else:
        return -1


    
l = input().split()
n = int(l[0])
m = int(l[1])

if n % 2 == 0:
    p = int(n/2)
else:
    p = int(n/2)+1

print(func(p,m,n))


n, m = map(int, input().split())
x = n // 2 + n % 2
while x <= n and x % m != 0:
    x += 1
if x > n:
    print(-1)
else:
    print(x)

n,m = list(map(int, input().split(' ')))
x = n//2 + (n%2==1)
y = n
for i in range(x, y+1) :
    if i%m == 0 :
        print(i)
        break
else :
    print(-1)


n, m = map(int, list(input().split()))

min_v = n // 2 + n % 2
while min_v % m != 0:
    min_v += 1
if min_v > n:
    print('-1')
else:
    print(min_v)

n,m=map(int,input().split())
a=0
b=n%2
n=n-b
for i in range(n//2,n+1):
   if a==0:
      if (i+b)%m==0:
         print(i+b)
         a=1
if a==0:print(-1)

n, m = map(int, input().split())
for i in range(n//2+n%2, n+1):
    if i % m == 0:
        print(i)
        break
else:
    print(-1)

#! /usr/bin/env python3

def main(n, m):
    if n < m:
        return -1
    temp = int(n / 2) + n % 2
    while temp % m != 0 and temp < n:
        temp = temp + 1
    return temp if temp % m == 0 else -1

n, m = input().split(' ')
n, m = int(n), int(m)

print(main(n, m))

# Codeforces Round 272d2 problem A

inp = tuple(map(int, input().split(' ')))
n, m = inp

s1 = n % 2
s2 = n // 2

while (s1+s2) % m != 0 and s2 > 0:
    s2 -= 1
    s1 += 2

if s2 == 0 and s1 % m != 0:
    print(-1)
else:
    print(s1 + s2)
    
    


n, m = list(map(int, input().split()))
Min = (n + 1) // 2;
while Min <= n and Min % m != 0:
	Min += 1;
if Min <= n:
	print(Min)
else:
	print(-1)


import math

#input

n,m=list(map(int,input().split()))



#variables
minimum=math.ceil(n/2)
i=minimum-1



#main

while True:
	i+=1
	if i%m==0:
		print(i)
		quit()
	if i==n:
		print(-1)
		quit()


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

(n,m) = list(map(int,input().split()))

ok = False
for step2 in range(n//2, -1, -1):
    step = step2 + (n - 2 * step2)
    if step % m == 0:
        print(step)
        ok = True
        break
    
if not ok:
    print(-1)


'''
Created on Oct 12, 2014

@author: Ismael
'''
ok = False
n,m = map(int,input().split())
for y in range(n//2,-1,-1):
    if((n-y)%m==0):
        print(y+(n-2*y))
        ok = True
        break
if(not ok):
    print(-1)

n, m = list(map(int, input().split()))
k  = n // 2 + n % 2
l = n % 2
while k % m != 0 and l <= n:
    k += 1
    l += 2
print(k if k % m == 0 and k <= n else -1)


n,m=map(int,input().split())

if n<m:print(-1)
else:
    x=n//2+n%2
    while x%m!=0:
        x+=1
    print(x)

def main():
    n, m = input().split(' ')
    n = int(n)
    m = int(m)
    res = 0
    if n < m:
        print("-1")
    else:
        if n % 2 != 0:
            n -=1
            res += 1
        shag_count2 = n / 2
        if (shag_count2 + res) % m == 0:
            print(int(shag_count2 + res))
        else:
            while (shag_count2 + res) % m != 0:
                res += 1
            print(int(shag_count2 + res))


def __starting_point():
    main()

__starting_point()

def main():
    nAndM = str(input()).split()
    n, m = int(nAndM[0]), int(nAndM[1])
    maxX = n//2
    answers = []
    for x in range(maxX + 1):
        y = n - 2*x
        if (x + y) % m == 0:
            answers.append(x + y)
        answers.sort()
    if answers:
        print(answers[0])
    else:
        print(-1)

def __starting_point():
    main()
__starting_point()

import math

x=[int(i) for i in input().split()]
n=x[0]
m=x[1]
if(n%2==0):
    s = math.ceil((n//2)/m)
else:
    s= math.ceil(((n+1)//2)/m)

if(s*m <= n ):
    print(s*m)
else:
    print(-1)

n, m = [int(i) for i in input().split()]
for i in reversed(list(range(0, n // 2 + 1))):
	s = i + n - 2 * i
	if s % m == 0:
		print(s)
		break
else:
	print(-1)


import math
n,m = list(map(int,input().split()))
res = 0
if n==0:
    print(0)
    quit()

if m>n:
    print(-1)
    quit()

"""if n%2==0:
    res = (n//2)

else:
    res = (n//2+1)
print(res+n%m)"""
for i in range((n+1)//2,n+1):
    if i%m==0:
        print(i)
        quit()


#!/usr/bin/env python
# -*- coding:utf-8 -*-


def main():
    n,m = [ int(x) for x in input().split(' ') ]

    res = 0
    while True:
        if n < 0:
            res = -1
            break

        q = n // 2
        r = n % 2
        if r != 0 :
            res += 1
            n -= 1
            continue

        if ( q + res ) % m == 0:
            res += q
            break;

        res += 1
        n -= 1

    print( res )
    return

def __starting_point():
    main()

__starting_point()

n,m=list(map(int,input().split()))
if n%2==0:
    a=n//2
    b=(n//2)*2
if n%2!=0:
    a=n//2+1
    b=(n//2)*2+1
o=-1
for i in range(a,b+1):
    if i%m==0:
        o=i
        break
print(o)


n, m = list(map(int, input().split()))
if n < m:
    print(-1)
else:
    k = (n + 2 * m - 1) // (2 * m)
    x = n - k * m
    y = 2 * k * m - n
    print(x + y)


n, m=input().split()
n=int(n)
m=int(m)
flag=0
res=0
if m>n:
    print(-1)
else:
    while n>=2*m:
        res+=m
        n-=2*m
    if n%(2*m)!=0:
        res+=m
    print(res)
    


'''
Created on Oct 12, 2014

@author: Ismael
'''
ok = False
n,m = map(int,input().split())
for y in range(n//2,-1,-1):
    if((n-y)%m==0):
        print(y+(n-2*y))
        ok = True
        break
if(not ok):
    print(-1)

n, m = map(int, input().split())
ans = -1
for i in range((n+1)//2, n+1):
    if i%m==0:
        ans = i
        break
print(ans)