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