#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
int n,s,t;
while(~scanf("%d%d%d",&n,&s,&t))
{
if(n==1){cout<<"0\n";goto k;}
if(s==1&&t==n){cout<<"0\n";goto k;}
if(n==1&&t==s){cout<<"0\n";goto k;}
if(s==t){cout<<"-1\n";goto k;}
if(n==3){cout<<"0\n";goto k;}
if(t+1==s){cout<<"1\n";goto k;}
if(s+1==t){cout<<"1\n";goto k;}
if(t==1||t==n){cout<<"2\n";goto k;}
if(s==1||s==n){cout<<"1\n";goto k;}
else cout<<"2\n";
k: n=s=t=0;
}
return 0;
}