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