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