#include <bits/stdc++.h>
using namespace std;
int x, n;
long long power(int i, long long k) {
  long long ans = 1;
  while (i--) {
    ans *= k;
  }
  return ans;
}
bool check(long long v) {
  long long ans = v;
  for (int i = 1; true; i++) {
    if (v / (power(i, x)) == 0) {
      break;
    }
    ans += v / (power(i, x));
    if (ans >= n) {
      return true;
    }
  }
  if (ans >= n) {
    return true;
  }
  return false;
}
long long binarySearch() {
  long long low = 1, high = 1e9 + 1, mid;
  while (high - low > 0) {
    mid = (low + high) / 2;
    if (check(mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  return low;
}
int main() {
  scanf("%d %d", &n, &x);
  printf("%lld\n", binarySearch());
  return 0;
}
