#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int n, s, t; while(~scanf("%d%d%d", &n, &s, &t)) { if(s == t && n != 1) { printf("-1\n"); continue; } if(s == 1 && t == n) { printf("0\n"); continue; } if(s == n && t == 1) { printf("0\n"); continue; } if(abs(s - t) == 1) { printf("1\n"); continue; } if(s == 1 && t != n) { printf("1\n"); continue; } if(s == n && t != 1) { printf("1\n"); continue; } printf("2\n"); } return 0; }