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