#include <iostream>
using namespace std;
int main(){
int n, st, ed; cin >> n >> st >> ed;
st -- , ed -- ;
int stx, sty;
int edx, edy;
stx = st / n;
if(stx % 2 == 1) sty = n - st % n - 1;
else sty = st % n;
edx = ed / n;
if(edx % 2 == 1) edy = n - ed % n - 1;
else edy = ed % n;
cout << abs(stx - edx) + abs(sty - edy) << endl;
return 0;
}