#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
int main() {
  int n, m, a, b;
  int r, r1, r2;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  if (b % m == 0)
    r1 = b / m;
  else
    r1 = b / m + 1;
  if (a % m == 0)
    r2 = a / m;
  else
    r2 = a / m + 1;
  r = r1 - r2 + 1;
  if (((a - 1) % m == 0 && (b % m == 0 || b == n)) || r == 1) {
    printf("1\n");
    return 0;
  } else if (((a - 1) % m - (b - 1) % m == 1) || r == 2 || (a - 1) % m == 0 ||
             b % m == 0 || b == n) {
    printf("2\n");
    return 0;
  } else
    printf("3\n");
  return 0;
}
