#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int r = 0, c = 0, x = n;
  r = n + n / m;
  c = n / m;
  while (r < r + r / m - c) {
    n = r + r / m - c;
    c = r / m;
    r = n;
  }
  cout << r << endl;
  return 0;
}
