#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	ll N,k,ans = 0;

	scanf("%lld %lld",&N,&k);

	for(int i = 0; i < N-1; i++){
		ans += ans/(k-1)+1;
	}

	printf("%lld\n",ans);

	return 0;
}