#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x = 0;
  vector<int> v;
  cin >> n >> m;
  for (int i = 1; i <= n + x; i++) {
    if (i % m == 0) v.push_back(1);
    x = v.size();
  }
  cout << n + x << endl;
}
