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