#include <bits/stdc++.h>
using namespace std;
const int N = 51, oo = (1 << 29), Z = 501;
int n, m;
map<int, bool> vis;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= 10000; ++i) vis[m * i] = true;
  int px = 0;
  while (n > 0) {
    --n;
    ++px;
    if (vis[px]) ++n;
  }
  cout << px << endl;
  return 0;
}
