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