#include
#include
using namespace std;
void f(int w,int n,int &x,int &y)
{
x=(n-1)/w;
y=(n-1)%w;
if(x%2!=0)
y=w-1-y;
}
int main()
{
int w,m,n,x1,y1,x2,y2;
cin>>w>>m>>n;
f(w,m,x1,y1);
f(w,n,x2,y2);
cout<<abs(x1-x2)+abs(y1-y2)<<endl;
return 0;
}
//void f(int w,int n,int &x,int &y) 里面为什么要用&,是什么意思?