#include <bits/stdc++.h>
using namespace std;

vector<int> g[100000];
int dp[2][100000];
void dfs(int cur, int prev, int dist, int idx) {
  dp[idx][cur] = dist;
  for (int to: g[cur]) {
    if (to == prev) {
      continue;
    }
    dfs(to, cur, dist + 1, idx);
  }
}
int main() {
  int n, u, v;
  cin>>n>>u>>v;
  --u;
  --v;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(u, -1, 0, 0);
  dfs(v, -1, 0, 1);
  int ans = 0;
  for (int i=0; i<n; i++) {
    if (dp[0][i] < dp[1][i]) {
      ans = max(dp[1][i] - 1, ans);
    }
  }
  cout<<ans<<endl;
}