#include <bits/stdc++.h>
int main() {
  int m, n, a, b;
  int col1, col2, row1, row2;
  int sum;
  while (scanf("%d%d%d%d", &n, &m, &a, &b) == 4) {
    a--;
    b--;
    col1 = a % m, col2 = b % m;
    row1 = a / m, row2 = b / m;
    sum = 3;
    if ((b + 1) == n) col2 = m - 1;
    if ((col1 == 0 && col2 == m - 1) || (row1 == row2))
      sum = 1;
    else if (((row2 - row1) == 1) || (col2 == m - 1) || (col1 == 0) ||
             ((col1 - col2) == 1))
      sum = 2;
    printf("%d\n", sum);
  }
  return 0;
}
