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