#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int a, b;
int main() {
  cin >> n >> m >> a >> b;
  a--;
  b--;
  if (a / m == b / m || a % m == 0 && (b + 1 == n || b % m == m - 1))
    printf("1\n");
  else if (a / m + 1 == b / m || a % m == 0 || b % m == m - 1 || b + 1 == n ||
           a % m == b % m + 1)
    printf("2\n");
  else
    printf("3\n");
  return 0;
}
