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