#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);
vector<vector<int>> G;
void dfs(int now,vector<int> &dist){
  for(auto nv:G[now]){
    if(dist[nv]>=0)continue;
    dist[nv]=dist[now]+1;
    dfs(nv,dist);
  }
}
int main(){
  int n,u,v;
  cin >> n >> u >> v;
  u--;
  v--;
  G.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int>d1(n,-1),d2(n,-1);
  d1[u]=0;d2[v]=0;
  dfs(u,d1);
  dfs(v,d2);
  int ans=0;
  rep(i,n){
    if(d1[i]<d2[i]){
      ans = max(ans,d2[i]-1);
    }
  }
  cout << ans << endl;
  
}
