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