#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  int sp, ep, cnt = 1, midr;
  sp = (int)ceil(a * 1.0 / m);
  ep = (int)ceil(b * 1.0 / m);
  midr = ep - sp + 1;
  if (sp == ep || m == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (a % m != 1 && a != 1) {
    cnt++;
    midr--;
  }
  if (b % m != 0 && b != n) {
    cnt++;
    midr--;
  }
  if (midr <= 0)
    cnt--;
  else if ((b - 1) % m + 1 == (a - 1) % m)
    cnt = 2;
  cout << cnt << endl;
  return 0;
}
