#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
inline void read(int *a, int n) {
  for (int i = 0; i < n; i++) a[i] = in();
}
template <class blank>
inline void out(blank x) {
  cout << x << "\n";
  exit(0);
}
template <class blank>
inline void smin(blank &a, blank b) {
  a = min(a, b);
}
template <class blank>
inline void smax(blank &a, blank b) {
  a = max(a, b);
}
const int maxn = 1e5 + 5e4 + 10;
const int maxm = 1e6 + 10;
const int maxlg = 21;
const int base = 29;
const int mod = 1e9 + 7;
const int inf = 1e9 + 10;
const int SQ = 317;
int32_t main() {
  int n = in(), m = in(), a = in(), b = in();
  a--, b--;
  int where1 = a % m, where2 = b % m;
  if (a / m == b / m) out(1);
  if (where1 == 0 && b == n - 1) out(1);
  if (where1 == 0 && where2 == m - 1) out(1);
  if (where1 == 0) out(2);
  if (a / m + 1 == b / m) out(2);
  if (where2 == m - 1) out(2);
  if (b == n - 1) out(2);
  if (where1 == where2 + 1) out(2);
  out(3);
}
