#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long choose(long long n, long long m) {
  if (m == 0)
    return 1;
  else
    return n * choose(n - 1, m - 1) / m;
}
long long n, m, a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> a >> b;
  long long c = (a - 1) / m;
  long long d = (b - 1) / m;
  if (m == 1 || c == d || (a % m == 1 && (b % m == 0 || b == n)))
    cout << 1;
  else if (d - c == 1 || a % m == 1 || b % m == 0 || b == n ||
           ((b - 1) % m + 1 == (a - 1) % m))
    cout << 2;
  else
    cout << 3;
  return 0;
}
