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