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