#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b;
long long calc_col(long long x) {
  long long ret = x % m;
  if (ret == 0) {
    ret += m;
  }
  return ret;
}
signed main() {
  cin >> n >> m >> a >> b;
  long long h1 = (a - 1) / m, h2 = (b - 1) / m;
  long long c1 = calc_col(a), c2 = calc_col(b);
  if (b == n) {
    c2 = m;
  }
  if (c1 == 1 && c2 == m) {
    cout << 1 << endl;
    return 0;
  }
  if (h1 == h2) {
    cout << 1 << endl;
    return 0;
  }
  if (h1 + 1 == h2) {
    cout << 2 << endl;
    return 0;
  }
  if (c1 == 1 || c2 == m || c1 == c2 + 1) {
    cout << 2 << endl;
    return 0;
  }
  cout << 3 << endl;
  return 0;
}
