#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int w,m,n;
cin>>w>>m>>n;
m--,n--; //使得下标从0开始
int x1=m/w;
int x2=n/w;
int y1=m%w;
int y2=n%w;
if (x1%2==1) y1=w-1-y1; //奇数行需要翻转一下,归纳一下找找规律即可
if (x2%2==1) y2=w-1-y2;
cout<<abs(x1-x2)+abs(y1-y2)<<endl;
return 0;
}