#include <bits/stdc++.h>
using namespace std;
int n, k, v;
bool check(int v) {
  int sum = 0;
  sum += v;
  while (v / k > 0) {
    sum = sum + v / k;
    v /= k;
  }
  return sum >= n;
}
int main() {
  scanf("%d%d", &n, &k);
  v = n - n / k;
  while (!check(v)) v++;
  printf("%d", v);
  return 0;
}
