#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int sol = 0, tmp = 0;
  while (n) {
    n--;
    sol++;
    tmp++;
    if (tmp == m) {
      tmp = 0;
      n++;
    }
  }
  cout << sol << endl;
}
