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