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