#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 5;
int main() {
  long long n, m, a, b;
  cin >> n >> m >> a >> b;
  int st = a / m + (a % m != 0);
  int ed = b / m + (b % m != 0);
  if (m == 1) {
    cout << 1;
    return 0;
  }
  if (b == n) {
    if (a % m == 1 || st == ed)
      cout << 1;
    else
      cout << 2;
    return 0;
  }
  if ((a % m == 1 && b % m == 0) || st == ed) {
    cout << 1;
    return 0;
  }
  if (a % m == 1 || b % m == 0 || st + 1 == ed || (b + 1) % m == a % m)
    cout << 2;
  else
    cout << 3;
  return 0;
}
