#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  int n, m, a, b;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  int posA, posB;
  if (a % m == 0)
    posA = a / m;
  else
    posA = a / m + 1;
  if (b % m == 0)
    posB = b / m;
  else
    posB = b / m + 1;
  if (posA == posB || (b % m == 0 && (a - 1) % m == 0) ||
      (b == n && (a - 1) % m == 0)) {
    printf("1");
    return 0;
  }
  if (posB - posA == 1 || ((a - 1) % m == 0) || (b % m == 0) || (b == n)) {
    printf("2");
    return 0;
  }
  int k;
  k = m;
  int cA, cB;
  if (a % m == 0)
    cA = k;
  else
    cA = a % m;
  if (b % m == 0)
    cB = k;
  else
    cB = b % m;
  if (cA - cB == 1)
    printf("2");
  else
    printf("3");
  return 0;
}
