prison

There are an infinite number of prisoners. Initially, the prisoners are numbered 0, 1, 2, ....

Do the following N times:

* Release the 0th prisoner and execute the k, 2k, 3k, ... th prisoners.
* Then renumber the remaining prisoners. At this time, the prisoners with the smallest original numbers are numbered 0, 1, 2, ... in order.



Find the number that was originally assigned to the prisoner released in the Nth operation.

Constraints

* 1 ≤ N ≤ 10 ^ 5
* 2 ≤ k ≤ 10 ^ 5
* The answer is less than 10 ^ {18}.



Input Format

Input is given from standard input in the following format.


N k


Output Format

Print the answer in one line.

Sample Input 1


4 2


Sample Output 1


7


Sample Input 2


13


Sample Output 2


0


Sample Input 3


100000 100000


Sample Output 3


99999






Example

Input

4 2


Output

7
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll
void solve(){
	int n, k;
	cin >> n >> k;
	int ans = 0;
	REP(i, n-1) {
		ans += 1 + ans / (k - 1LL);
	}
	cout << ans << endl;
}

#undef int
int main() {
	init();
	solve();
}
