#include <bits/stdc++.h>
int main(void) {
  unsigned int m, n, a, b, a_pos, b_pos, a_line, b_line, k;
  scanf("%u %u %u %u", &m, &n, &a, &b);
  a_pos = (a - 1) % n + 1;
  b_pos = (b - 1) % n + 1;
  a_line = (a - 1) / n;
  b_line = (b - 1) / n;
  if (b == m) b_pos = n;
  if (a_line == b_line) {
    k = 1;
  } else if (a_pos == 1 && b_pos == n) {
    k = 1;
  } else if (a_pos == 1 || b_pos == n) {
    k = 2;
  } else if (b_pos + 1 == a_pos) {
    k = 2;
  } else if (a_line + 1 == b_line) {
    k = 2;
  } else {
    k = 3;
  }
  printf("%d\n", k);
  return 0;
}
