# h1,a1 = map(int, input().split())
# h2,a2 = map(int, input().split())
# t = 0
# k = 1
# while h2 > 0:
#     h2 -= a1
#     t += 1
# while h1 > 0:
#     h1 -= a2
#     k += 1
# if k > t:
#     print("Bandergolf")
# elif k < t:
#     print("Bendaril")
#
# a,b,l,n = map(int, input().split())
# o = 2*l+(2*n-1)*a+2*(n-1)*b
# print(o)

#
# a,b,c,d = map(int, input().split())
# if d <= b:
#     print(a)
# else:
#     print(a + (d - b) * c)













#
#
#
#
#
#                                 print(1)
#                                 print(3)
#                                 print(4)
#                             if n[j][i+5].isalpha():
#                             if n[j][i+5].isalpha():
#                             if n[j][i+5].isdigit():
#                             print(2)
#                         if n[j][i+4].isalpha():
#                         if n[j][i+4].isalpha():
#                         if n[j][i+4].isdigit():
#                         if n[j][i+4].isdigit():
#                     if n[j][i+3].isdigit():
#                     if n[j][i+3].isdigit():
#                     if n[j][i+3].isdigit():
#                     if n[j][i+3].isdigit():
#                 if n[j][i+2].isdigit():
#                 if n[j][i+2].isdigit():
#                 if n[j][i+2].isdigit():
#                 if n[j][i+2].isdigit():
#             if n[j][i+1].isalpha():
#             if n[j][i+1].isalpha():
#             if n[j][i+1].isdigit():
#             if n[j][i+1].isdigit():
#             print(0)
#         a.append(i)
#         count = 0
#         d.append('.')
#         else:
#         i = i * -1
#         if n[j][i].isalpha():
#         if n[j][i].isalpha():
#         if n[j][i].isalpha():
#         if n[j][i].isdigit():
#         o+= int(n[i]) * n[i+1]
#         o+=int(t)*n[i+2]
#         o+=n[i]
#         p+=1
#         print(count)
#         print(o)
#         print(o+c)
#         print(o+c+1)
#         t=n[i] + n[i+1]
#     a-=1
#     a-=1
#     b-=1
#     b-=1
#     c-=1
#     count += 1
#     count += w[t]
#     d.append(n[i])
#     d.pop(-1)
#     del otvet[t]
#     e = x2 - x1
#     else:
#     for i in range(len(n)):
#     g += c[t]
#     i+=1
#     if count == 3:
#     if i < 0:
#     if i == 0:
#     if n[i].isalpha():
#     if n[i].isdigit() and n[i+1].isdigit():
#     if n[i].isdigit():
#     if o + c >= 0:
#     if t == t1:
#     m = m - n
#     n = y2 - y1
#     n.append(str(input()))
#     n1 += i
#     o += m / 2
#     o += m / 2 + 1
#     o = (w[i] / c[i])
#     o = a-b-1
#     o = o * g[i]
#     o = o * n
#     o = o * n
#     otvet.append(o)
#     p+=i*2
#     print(a-b+c)
#     print(g)
#     print(t)
#     s = y1 - y2
#     t = otvet.index(max(otvet))
#     t = str(i)
#     t+=1
#     t+=1
#     t+=1
#     t+=1
#     t+=1
#     t1 = t[::-1]
#     w = x1 - x2
# a = []
# a = int(input())
# a = int(input())
# b = int(input())
# b = int(input())
# c = int(input())
# c = int(input())
# c = list(map(int,input().split()))
# count = 0
# count = 0
# count = 0
# d = []
# e= 0
# else:
# else:
# else:
# else:
# for i in d:
# for i in g:
# for i in l:
# for i in range(0,3):
# for i in range(3):
# for i in range(k):
# for i in range(len(n)):
# for i in range(len(n)):
# for j in range(len(n)):
# from collections import deque
# g = 0
# g = list(map(int, input().split()))
# g.sort(reverse=True)
# i = 0
# if a-b<=0:
# if a>0 and a-b>=1:
# if len(n) % 3 == 0:
# if m % 2 == 0:
# if n % 2 == 0:
# if x1 < x2:
# if y1 < y2:
# l = list(map(int, input().split()))
# m = int(input())
# m = int(input())
# n = []
# n = input()
# n = input()
# n = int(input())
# n = int(input())
# n = int(input())
# n = int(input())
# n = int(input())
# n,k = map(int, input().split())
# n1 = ''
# n= 0
# o = ''
# o = (e * 'e')+(w*'w')+(n*'n')+(s*'s')
# o = 0
# o = 0
# o = 1
# otvet = []
# p = 0
# print(a[n])
# print(g)
# print(int(o))
# print(m)
# print(n)
# print(n)
# print(n1)
# print(o)
# print(o)
# print(o)
# print(p)
# put your python code here
# s= 0
# t = ''
# t = 0
# w = list(map(int,input().split()))
# w= 0
# while a != 0 or b != 0 or c != 0:
# while count <= n:
# while i < 1000:
# while m > n:
# x1 = int(input())
# x2 = int(input())
# y1 = int(input())
# y2 = int(input())

# l = []
# n = str(input())
# for i in n:
#     l.append(i)
# if len(n) > 10:
#     print(l[0] + str(len(n)-2) + l[-1])
# else:
#     print(n)
# l = []
# N = int(input())
# word_idx = 0
# for i in range(N):
#    word = str(input())
#    if len(word) <= 10:
#       l.append(word)
#    else:
#       sym_list = list(word)
#       t = "".join( sym_list[:1] + [str(len(word) - 2)] + sym_list[-1:])
#       l.append(t)
# for i in l:
#     print(i)
k=0
t = 0
n,m = map(int, input().split())
while n != 0:
    n-=1
    t+=1
    if t == m:
        n+=1
        t = 0
    k+=1
print(k)
