#include <bits/stdc++.h>
using namespace std;
long long m, n, a, b;
long long Ans;
void Solve1() {
  if (b - a + 1 <= m || (b - a + 1) % m == 0 || b == n) {
    cout << 1 << endl;
    return;
  }
  cout << 2 << endl;
}
void Solve2() {
  long long w = m - (a - 1) % m;
  if (b - a + 1 - w <= 0) {
    cout << 1 << endl;
    return;
  }
  if (b - a + 1 - w <= m) {
    cout << 2 << endl;
    return;
  }
  if (b == n) {
    cout << 2 << endl;
    return;
  }
  if ((b - a + 1) % m == 0) {
    cout << 2 << endl;
    return;
  }
  if ((b - a + 1 - w) % m == 0) {
    cout << 2 << endl;
    return;
  }
  cout << 3 << endl;
}
int main(int argc, char** argv) {
  while (cin >> n >> m >> a >> b) {
    if (n <= m || m == 1) {
      cout << 1 << endl;
      continue;
    }
    if (a % m == 1)
      Solve1();
    else
      Solve2();
  }
  return 0;
}
