#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int fact[1000100 + 10], inv[1000100 + 10];
long long int fpow(long long int a, long long int b) {
  long long int ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ret;
}
long long int strint(char str[]) {
  long long int ret = 0;
  for (int i = 0; i < strlen(str); i++) ret = (ret * 10 + str[i] - '0') % mod;
  return ret;
}
long long int invmod(long long int a) { return fpow(a, mod - 2); }
long long int precalc() {
  fact[0] = 1;
  fact[1] = 1;
  inv[0] = 1;
  inv[1] = 1;
  for (long long int i = 2; i < 1000100 + 10; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    inv[i] = invmod(i);
  }
}
long long int factorize(int n) {
  long long int ret = 0, f = 0;
  for (int i = 2; i * i <= n; i++) {
    f = 0;
    while (n % i == 0) {
      f++;
      n /= i;
    }
    if (f) ret++;
  }
  if (n > 2) ret++;
  return ret;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
bool chkPrimeExtra(int n) {
  if (n == 0 || n == 1) return false;
  if (n % 2 == 0) return false;
  for (int i = 3; i * i <= n; i += 4)
    if (n % i == 0 or (n % (i + 2)) == 0) return false;
  return true;
}
int chkPrime(int n) {
  int count = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i == n)
        count++;
      else
        count += 2;
    }
  }
  if (count == 2)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
  return count;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int i, lv, nn, mm, in = 0, ix = 0, mx = LONG_LONG_MIN,
                               mn = LONG_LONG_MAX, x, f = 0;
  scanf("%lld", &nn), scanf("%lld", &mm);
  in = nn;
  long long int ans = nn + (nn - 1) / (mm - 1);
  printf("%lld", ans);
}
