#include <bits/stdc++.h>
using namespace std;
int n, k;
int re(int v) {
  int p = v;
  int otv = v;
  while (p / k) {
    otv += p / k;
    p /= k;
  }
  if (otv >= n)
    return v;
  else
    return re(v + 1);
}
int main() {
  cin >> n >> k;
  int v = n - n / k;
  cout << re(v);
}
