#include <bits/stdc++.h>
using namespace std;
int arr[3000];
int main() {
  int n, m, x = 0;
  cin >> n >> m;
  int tmp = n;
  for (int i = m; i < n; i += m) {
    n++;
  }
  tmp += n / m;
  cout << tmp;
  cin >> n;
}
