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