#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 0, +1, -1, -1, +1, +1};
const int dy[] = {0, -1, +1, 0, -1, +1, -1, +1};
int n, m, a, b;
int main() {
  int x1, x2, y1, y2;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  x1 = a / m + 1;
  y1 = a % m;
  if (y1 == 0) {
    x1--;
    y1 = m;
  }
  x2 = b / m + 1;
  y2 = b % m;
  if (y2 == 0) {
    x2--;
    y2 = m;
  }
  if (x1 == x2)
    printf("1");
  else if (b == n) {
    if (y1 == 1)
      printf("1");
    else
      printf("2");
  } else if (x1 + 1 == x2) {
    if (y1 == 1 && y2 == m)
      printf("1");
    else
      printf("2");
  } else {
    if (y1 == 1) {
      if (y2 == m)
        printf("1");
      else
        printf("2");
    } else {
      if (y2 + 1 == y1 || y2 == m)
        printf("2");
      else
        printf("3");
    }
  }
  return 0;
}
