#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, counter = 0;
  bool day = false;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    counter++;
    if (i % m == 0) {
      day = true;
    }
    if (day) {
      n++;
      day = false;
    }
  }
  cout << counter << endl;
  return 0;
}
