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