#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c, a, b;
  scanf("%d %d %d %d", &n, &c, &a, &b);
  a--;
  b--;
  int ca = a % c, cb = b % c;
  if (ca == 0) {
    if ((cb == (c - 1)) or b == (n - 1))
      printf("1\n");
    else if (b / c == a / c)
      printf("1\n");
    else
      printf("2\n");
  } else if (cb == (c - 1)) {
    if (b / c == a / c)
      printf("1\n");
    else
      printf("2\n");
  } else if (a / c == b / c)
    printf("1\n");
  else if (b / c == a / c + 1)
    printf("2\n");
  else if (b == (n - 1))
    printf("2\n");
  else if (b % c == (a % c) - 1)
    printf("2\n");
  else
    printf("3\n");
  return 0;
}
