
#include <bits/stdc++.h>
#define rep(i,n) for (double i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
const int INF=1001001001;



vector<ll> dist;
vector<ll>g[200005];


void dfs(ll v,ll p, ll d){
  dist[v]=d;
  for(ll to:g[v]){
    if (to==p)continue;
    dfs(to,v,d+1);
  }
}

int main(){
  ll n,u,v;
  cin>>n>>u>>v;
  u--;v--;
  rep(i,n-1){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    g[a1].push_back(b1);
    g[b1].push_back(a1);
  }
  vector<ll> dist1,dist2;
  dist=vector<ll>(n);
  dfs(u,-1,0);
  dist1=dist;
  dist=vector<ll>(n);
  dfs(v,-1,0);
  dist2=dist;
  ll ml=0;
  rep(i,n){
    if (dist1[i]<dist2[i]){
      ml=max(ml,dist2[i]);
  //    cout<<dist1[i]<<" "<<dist2[i]<<endl;
  //    cout<<ml<<"i"<<i<<endl;
    }
  }
  cout<<ml-1;

}
