#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, A, B;
inline void pan1() {
  int l = A / m + 1 - (A % m == 0);
  int r = B / m + 1 - (B % m == 0);
  int L = A - (l - 1) * m, R = B - (r - 1) * m;
  if (l == r || m == 1 || L == 1 && B == n || L == 1 && R == m) {
    printf("1\n");
    exit(0);
  }
}
inline void pan2() {
  int l = A / m + 1 - (A % m == 0);
  int r = B / m + 1 - (B % m == 0);
  int L = A - (l - 1) * m, R = B - (r - 1) * m;
  if (L == 1 || R == m || R + 1 == L || B == n || l + 1 == r) {
    printf("2\n");
    exit(0);
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &A, &B);
  pan1(), pan2();
  printf("3\n");
  return 0;
}
