#include <bits/stdc++.h>
int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  int n = c / b;
  if (c % b != 0) {
    n++;
  }
  int m = d / b;
  if (d % b != 0) {
    m++;
  }
  if (c % b == 1 && d % b == 0 || n == m || b == 1 ||
      (d == a && (n == m || c % b == 1))) {
    printf("1\n");
    return 0;
  } else if ((c % b != 1 && d != a) && ((d + 1) % b != c % b) && m - n > 1 &&
             d % b != 0) {
    printf("3\n");
    return 0;
  } else {
    printf("2\n");
    return 0;
  }
}
