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