Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?


-----Input-----

The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.


-----Output-----

Print a single integer — the answer to the problem.


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

Output
3

Input
9 3

Output
13



-----Note-----

In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.

In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Contest 262 Div 2 Problem A

Author  : chaotic_iak
Language: Python 3.3.4
"""

def main():
    n,m = read()
    i = 0
    while n:
        n -= 1
        i += 1
        if not i%m: n += 1
    print(i)

################################### NON-SOLUTION STUFF BELOW

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())

n, m = map(int, input().split())
day = 1
while n > 0:
    n -= 1
    if day % m == 0:
        n += 1
    day += 1

print(day - 1)

n, m = map(int, input().split())
count = n
day = 1
while count != 0:
    count -= 1
    if day % m == 0:
        count += 1
    if count!=0:
        day+=1
print(day)

n, m = map(int, input().split())
day = 0
while n != 0:
    day += 1
    n -= 1
    if (day % m == 0):
        n += 1
    
print(day)

3

import sys


def __starting_point():

    n, m = list(map(int, sys.stdin.readline().split()))
    d = 0
    while n > 0:
        d += 1
        n -= 1
        if d % m == 0:
            n += 1

    print(d)

__starting_point()

n,m = [int(x) for x in input().split()]
i = 0
while n > 0:
     n -= 1
     i += 1
     if i % m == 0:
         n += 1
print(i)


n,m = map(int, input().split())
cd = 0
while n > 0:
    cd += 1
    n -= 1
    if cd % m == 0:
        n += 1
print(cd)

n, m = list(map(int, input().split()))
r = 0
while n >= m:
    r += m
    n -= m - 1
print(r + n)


n,m = [int(i) for i in input().split()]
time = 0
import sys
while n > 0:
	if n < m:
		print(time+n)
		return
	n -= m-1
	time += m

n,m=map(int,input().split())
ans=1
while n!=0:
    if ans%m==0:
        n+=1
    n-=1
    ans+=1
print(ans-1)

def main():
    n, m = [int(i) for i in input().split()]
    
    day = 1
    while n > 0:
        if day % m == 0:
            n += 1
        n -= 1
        day += 1
    
    print(day - 1)


main()


def main():
	n,m=map(int,input().split(" "))
	d=0
	while True:
		d+=1
		n-=1
		if d % m == 0:
			n+=1
			pass
		if n == 0:
			break
			pass
		pass
	print (d)
	pass

main()

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

aux = [1 for i in range(n + 1)]
ans = 0
i = 1
while i < len(aux):
    
    if i % m == 0:
        aux.append(1)
    ans += 1
    i += 1

print(ans)

# Codeforces 262 Div. 2
# P1

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

c = 0
p = 1
while n != 0:
    n -= 1
    if p == m:
        n += 1
        p = 1
    else:
        p += 1
    c += 1
    
print(c)


n, m = [int(i) for i in input().split()]
a = [0] * 300
for i in range(m, 300, m):
    a[i + 1] = 1
k = 0
while k < 299 and n > 0:
    k += 1
    if a[k] == 1:
        continue
    a[k] = 1
    n -= 1
for i in range(1, 300):
    if a[i] == 0:
        k = i - 1
        break
print(k)
    


a=[int(i) for i in input().split()]
n=a[0]
m=a[1]
s=0
while n>=m:
    s+=m
    n=n-m+1
s+=n
print(s)

n, m = map(int, input().split())
count = 0
i = 0

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

n,m = list(map(int,input().split()))
t = 0
while(n!=0):
	n = n-1
	t = t+1
	if(t%m==0):
		n= n+1
print(t)


def solve():
    n,m=list(map(int,input().split()))
    i=0
    while n!=0:
        i+=1
        n-=1
        if i%m==0:
            n+=1
    print(i)
solve()


n, m = list(map(int, input().split()))
day = 0
while True:
    if n == 0:
        print(day)
        break
    n -= 1
    if day % m == m - 1:
        n += 1
    day += 1


n,m = list(map(int,input().split()))
c = 0
while n!=0:
    n-=1
    c+=1
    if c%m==0:
        n+=1
print(c)
    


n, m = list(map(int, input().split()))
now = n
day = 1
while now > 0:
    now -= 1
    if day % m == 0:
        now += 1
    day += 1
print(day - 1)


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

d = 1
while n > 0:
    if d % m == 0:
        n += 1
    n-= 1
    d+= 1


print(d-1)

n, m = map(int, input().split())
day, c = 0, 1
while n != 0:
    day += 1
    if day == (c*m):
        n += 1
        c += 1
    n -= 1
print(day)

lst, n, v = list(map(int, input().split(" "))), 0, 0
if lst[0] == 1 and lst[1] == 1:
    print(2)
else:
    while lst[0] > v:
        n += 1
        if n == lst[1]:
            lst[0] += 1
            n = 0
        v += 1
    print(lst[0])