#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, ra, rb, ca, cb;
  cin >> n >> m >> a >> b;
  ra = (a / m) + 1;
  rb = (b / m) + 1;
  if (a % m == 0) {
    ca = m;
    ra--;
  } else
    ca = a % m;
  if (b % m == 0) {
    cb = m;
    rb--;
  } else
    cb = b % m;
  if (ra == rb)
    cout << 1 << endl;
  else {
    if (ca == 1) {
      if (cb == m || b == n)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    } else {
      if (rb - ra == 1)
        cout << 2 << endl;
      else {
        if (ca - cb == 1 || cb == m || b == n)
          cout << 2 << endl;
        else
          cout << 3 << endl;
      }
    }
  }
  return 0;
}
