s = input().split() N = int(s[0]) k = int(s[1]) new = N//k new2 = new while(new >= k): new2 = new + (new // k) new = new // k print(N+new2)