#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, s, e;
  scanf("%d%d%d%d", &n, &k, &s, &e);
  int ans = 0;
  int first = (s - 1) / k, mid, end = e / k;
  if (first == end)
    printf("1\n");
  else {
    if ((s - 1) % k) ans++;
    int up;
    if ((s - 1) % k == 0)
      up = 0;
    else
      up = k - (s - 1) % k;
    if (e == n || e - s + 1 - up - e % k) ans++;
    if (e % k && e != n) ans++;
    int len = s % k ? (s % k) : k;
    if (ans == 3 && (len - e % k == 1)) ans = 2;
    printf("%d\n", ans);
  }
}
