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 _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

//typedef pair<long long int, long long int> P;
long long int INF = 1e18;

long long int N, K;

bool check(long long int A){
	long long int hoge = A;
	for(int i = 0; i < N - 1; i++){
		hoge -= hoge / K + (hoge % K > 0);
	}
	return (hoge > 0);
}

long long int bin_search(long long int lef, long long int rig){
	long long int middle = (lef + rig) / 2;
	//cout << middle << " ";
	if(rig - lef <= 1){
		if(check(lef)){
			return lef;
		}else{
			return rig;
		}
	}
	if(check(middle)){
		rig = middle;
	}else{
		lef = middle;
	}
	return bin_search(lef, rig);
}

int main(){
	
	cin >> N >> K;
	
	cout << bin_search(0, 1e18 + 1) - 1 << endl;
	
	return 0;
}
