#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, fx, fy, ex, ey;
int main() {
  cin >> n >> m >> a >> b;
  fx = (a - 1) / m + 1;
  fy = a % m;
  if (!fy) fy = m;
  ex = (b - 1) / m + 1;
  ey = b % m;
  if (!ey) ey = m;
  if (b == n) ey = m;
  if (fx == ex || (fy == 1 && ey == m)) {
    cout << 1;
    return 0;
  }
  if (fx + 1 == ex || fy == 1 || ey + 1 == fy || ey == m) {
    cout << 2;
    return 0;
  }
  cout << 3;
  return 0;
}
