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