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