#include <bits/stdc++.h>
using namespace std;
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
}
int main() {
  fastIO();
  int n;
  int m;
  int total;
  int day = 0;
  cin >> n >> m;
  while (n != 0) {
    day++;
    n = n - 1;
    if (day % m == 0) {
      n = n + 1;
    }
  }
  cout << day << endl;
  return 0;
}
