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