#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a, b;
  cin >> n >> m >> a >> b;
  long long column = (b - 1) / m - (a - 1) / m;
  long long row_a = a % m;
  long long row_b = b % m;
  if (m == 1) {
    cout << 1 << endl;
    return 0;
  }
  switch (column) {
    case 0:
      cout << 1 << endl;
      return 0;
    case 1:
      if (row_a == 1 && (row_b == 0 || n == b)) {
        cout << 1 << endl;
        return 0;
      }
      cout << 2 << endl;
      return 0;
    default:
      if (row_a == 1 && (row_b == 0 || n == b)) {
        cout << "1" << endl;
        return 0;
      } else if ((a - 1) % m == b % m || row_b == 0 || row_a == 1 || b == n) {
        cout << 2 << endl;
        return 0;
      }
      cout << 3 << endl;
      return 0;
  }
}
