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