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