#include<bits/stdc++.h>
using namespace std;
int main(){
int k,n,m;
cin>>k>>n>>m;
n--,m--;
int n1,n2,m1,m2;
n1=n/k,n2=n%k;
m1=m/k,m2=m%k;
if(n1%2)n2=k-1-n2;
if(m1%2)m2=k-1-m2;
cout<<abs(n1-m1)+abs(n2-m2)<<endl;
return 0;
}