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