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