#include <bits/stdc++.h>
int main() {
  int n, m, count, x;
  while (scanf("%d %d", &n, &m) == 2) {
    x = 0;
    count = 0;
    while (n != 0) {
      count++;
      if (count % m == 0) x = 1;
      n = (n - 1) + x;
      x = 0;
    }
    printf("%d\n", count);
  }
  return 0;
}
