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