#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, cnt = 0, t = 1;
  cin >> n >> m;
  while (n - t >= 0) {
    if (t % m == 0) {
      n = n + 1;
    }
    cnt++;
    t++;
  }
  cout << cnt;
  return 0;
}
