import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
{
long m, n, a, b;
Scanner in
= new Scanner
(System.
in); m = in.nextLong();
n = in.nextLong();
a = in.nextLong();
b = in.nextLong();
long dm = ((a + 1)/2 - 1) %m - ((b + 1)/2 - 1) % m;
long dn = (a - 1)/(2 * m) - (b - 1)/(2 * m);
long o
= dm
* dn
< 0? Math.
min(Math.
abs(dm
),
Math.
abs(dn
)) : 0; long k = dm > 0? 1: -1;
a += 2*k*o*(m - 1);
System.
out.
print( ((a
+ b
) % 2 == 0? 0: Math.
max(a, b
) % 2 == 0? 1: -1) + 2*(Math.
abs(dm
) + Math.
abs(dn
) - o
));
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWxvbmcgbSwgbiwgYSwgYjsKCQlTY2FubmVyIGluID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQltID0gaW4ubmV4dExvbmcoKTsKCQluID0gaW4ubmV4dExvbmcoKTsKCQlhID0gaW4ubmV4dExvbmcoKTsKCQliID0gaW4ubmV4dExvbmcoKTsKICAgIAlsb25nIGRtID0gKChhICsgMSkvMiAtIDEpICVtIC0gKChiICsgMSkvMiAtIDEpICUgbTsKICAgIAlsb25nIGRuID0gKGEgLSAxKS8oMiAqIG0pIC0gKGIgLSAxKS8oMiAqIG0pOwogICAgCWxvbmcgbyA9IGRtICogZG4gPCAwPyBNYXRoLm1pbihNYXRoLmFicyhkbSksIE1hdGguYWJzKGRuKSkgOiAwOwogICAgCWxvbmcgayA9IGRtID4gMD8gMTogLTE7CiAgICAJYSArPSAyKmsqbyoobSAtIDEpOwogICAgCVN5c3RlbS5vdXQucHJpbnQoICgoYSArIGIpICUgMiA9PSAwPyAwOiBNYXRoLm1heChhLCBiKSAlIDIgPT0gMD8gMTogLTEpICsgMiooTWF0aC5hYnMoZG0pICsgTWF0aC5hYnMoZG4pIC0gbykpOwoKCX0KfQ==