#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
void GetPonit(int a,int b,int &x,int &y)
{
x=b/a+1;
if(b%a==0)x-=1;
if(x % 2==0)
{
y=b%a;
if(y==0)y=a;
}
else
{
if(b%a)y=a-b%a+1;
else y=1;
}
}
int main()
{
int a,b,c,x1,y1,x2,y2;
cin>>a>>b>>c;
GetPonit(a,b,x1,y1);
GetPonit(a,c,x2,y2);
int ans=abs(x1-x2)+abs(y1-y2);
cout<<ans<<endl;
return 0;
}