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