#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l, r;
  cin >> n >> m >> l >> r;
  l--;
  r--;
  if (r == n - 1) {
    r += m - r % m - 1;
  }
  if (l / m == r / m) {
    cout << 1 << endl;
  } else if (l / m + 1 == r / m) {
    if (l % m == 0 && r % m == m - 1)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  } else {
    if (l % m == 0 && r % m == m - 1)
      cout << 1 << endl;
    else if (l % m != 0 && r % m == m - 1)
      cout << 2 << endl;
    else if (l % m == 0 && r % m != m - 1)
      cout << 2 << endl;
    else if (l % m != 0 && r % m != m - 1) {
      if (r % m + 1 == l % m)
        cout << 2 << endl;
      else
        cout << 3 << endl;
    }
  }
  return 0;
}
