#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, q = 0;
  cin >> n >> m;
  if (n < m) {
    cout << n;
    return 0;
  } else {
    q = n;
    n = (n - 1) / (m - 1);
    q += n;
  }
  cout << q;
}
