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