#include <bits/stdc++.h>
using namespace std;
const int maxn = 100009;
const int maxm = 100009;
const int maxk = 100009;
int n, m, a, b;
void put(int ans) {
  printf("%d\n", ans);
  exit(0);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  int l1, s1, l2, s2;
  l1 = (a - 1) / m;
  l2 = (b - 1) / m;
  s1 = a % m;
  s2 = b % m;
  if (l1 == l2 || m == 1) put(1);
  if ((s1 == 1 || a == 1) && (s2 == 0 || b == n)) put(1);
  if ((s1 == 1 || a == 1) || (s2 == 0 || b == n)) put(2);
  if (s1 == 0) s1 = m;
  if ((m - s1 + 1) + s2 == m) put(2);
  if (l2 - l1 == 1) put(2);
  put(3);
  return 0;
}
