#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> c(100100,vector<int> (0));
int N;

void DFS(int p,int ans,vector<bool> &b,vector<int> &d){
  if(b.at(p)){return;}
  
  if(!b.at(p)){
    b.at(p)=true;
    d.at(p)=ans;
    for(int i=0;i<c.at(p).size();i++){
      DFS(c.at(p).at(i),ans+1,b,d);
    }
  }
  return;
}

vector<int> dist(int p){
  vector<bool> b(N,false);
  vector<int> d(N);
  DFS(p,0,b,d);
  return d;
}

int main(){
  int T,A,ans=0;
  
  cin>>N>>T>>A;
  T--;A--;
  
  int s,t;
  for(int i=0;i<N-1;i++){
    cin>>s>>t;
    s--;t--;
    c.at(s).push_back(t);
    c.at(t).push_back(s);
  }
  
  vector<int> Td(N),Ad(N);
  Td=dist(T);
  Ad=dist(A);
  
  for(int i=0;i<N;i++){
    if(Td[i]<Ad[i]){ans=max(ans,Ad[i]-1);}
  }
  cout<<ans;
}
