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

using Graph = vector<vector<int>>;

void dfs(int v,const Graph &G,vector<int> &seen,vector<int> &dis) {
  seen[v] = 1;
  for(int nv:G[v]) {
    if(seen[nv]) continue;
    dis[nv] = dis[v] + 1;
    dfs(nv,G,seen,dis);
  }
}

int main() {

  int N,u,v;
  cin >> N >> u >> v;

  u--; v--;
  vector<vector<int>> e(N,vector<int>(0));
  for(int i = 0;i < N-1;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  vector<int> seen(N,0),T(N,0),A(N,0);
  dfs(u,e,seen,T);
  seen.assign(N,0);
  dfs(v,e,seen,A);

  int ans = 0;
  for(int i = 0;i < N;i++) {
    if(T.at(i) < A.at(i)) ans = max(ans,A.at(i));
  }

  cout << ans-1 << endl;



  
}
