#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e8;
int main() {
  int n, m, c = 0;
  cin >> n >> m;
  int ans = n;
  c = (n / m);
  while (c) {
    ans += 1;
    c -= 1;
    if (ans % m == 0) c += 1;
  }
  cout << ans;
  return 0;
}
