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