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
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n, K; cin >> n >> K;
    ll ans = 0;
    REP(t, n-1) {
        ans += ans/(K-1)+1;
    }
    cout << ans << endl;
}