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