#include <bits/stdc++.h>
int main() {
  int m, n;
  scanf("%d%d", &n, &m);
  int h = n;
  if (n == m)
    printf("%d", n + 1);
  else if (n < m)
    printf("%d", n);
  else {
    int k = n - 1;
    m = m - 1;
    m = k / m + n;
    printf("%d", m);
  }
}
