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