#include <bits/stdc++.h>
FILE *in = stdin, *out = stdout;
int n, m, s, e, sx, sy, ex, ey;
void input() {
  fscanf(in, "%d %d %d %d", &n, &m, &s, &e);
  sy = s % m;
  if (sy == 0) sy = m;
  sx = int((s - 1) / m) + 1;
  ey = e % m;
  if (ey == 0) ey = m;
  ex = int((e - 1) / m) + 1;
}
void pro() {
  if (sx == ex) {
    fprintf(out, "1");
    return;
  }
  if (e == n) {
    ey = m;
  }
  if (sy == 1) {
    if (ey < m) {
      fprintf(out, "2");
      return;
    }
    if (ey == m) {
      fprintf(out, "1");
      return;
    }
  }
  if (ey == m) {
    if (sy > 1) {
      fprintf(out, "2");
      return;
    }
    if (sy == 1) {
      fprintf(out, "1");
      return;
    }
  }
  if (ex == sx + 1 && sy <= ey) {
    fprintf(out, "2");
    return;
  }
  if (ex == sx + 1 && sy > ey) {
    fprintf(out, "2");
    return;
  }
  if (ex > sx + 1 && sy == ey + 1) {
    fprintf(out, "2");
    return;
  }
  if (ex > sx + 1 && sy <= ey) {
    fprintf(out, "3");
    return;
  }
  if (ex > sx + 1 && sy > ey + 1) {
    fprintf(out, "3");
    return;
  }
  fprintf(out, "3");
}
int main() {
  input();
  pro();
  return 0;
}
