#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    ll n, k, ans = 0;
    cin >> n >> k;
    REP(i,n-1){
        ans += (ans)/(k-1)+1;
    }
    cout << ans << endl;
    return 0;
}

