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