#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  int x = (a - 1) % m + 1;
  int y = (b - 1) % m + 1;
  int p = (a + m - 1) / m;
  int q = (b + m - 1) / m;
  if ((x == 1 && y == m) || (x == 1 && b == n) || (p == q)) {
    cout << "1" << endl;
  } else if (x == y + 1 || y == m || b == n || (p + 1 == q) || (x == 1)) {
    cout << "2" << endl;
  } else {
    cout << "3" << endl;
  }
}
