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