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