#include <bits/stdc++.h>
int main() {
  int n, m, a, b;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  int co = (a - 1) % m, cf = (b - 1) % m, lo = (a - 1) / m, lf = (b - 1) / m;
  if ((co == 0 && cf == m - 1) || (co == 0 && b == n) || lf == lo)
    printf("1");
  else if (b == n || co == 0 || cf == m - 1 || (lf - lo == 1) || (co - cf) == 1)
    printf("2");
  else
    printf("3");
  return 0;
}
