#include <bits/stdc++.h>
int main() {
  int n, m, l, k, j, i;
  scanf("%d%d", &n, &m);
  int st = n;
  i = 0;
  int day = 0;
  while (st > 0) {
    i++;
    st--;
    if (i % m == 0) st++;
  }
  printf("%d\n", i);
  return 0;
}
