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