#include<iostream>
#include<vector>
using namespace std;

int N, u, v;
vector<int> adj[100000];

void dfs(int now, int dist, int prev, vector<int> & vec){
  vec[now] = dist;
  for(auto next: adj[now]){
    if(next == prev){
      continue;
    }
    dfs(next, dist + 1, now, vec);
  }
}
    

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

  vector<int> dist_from_u (N, -1), dist_from_v(N, -1);
  dfs(u, 0, -1, dist_from_u);
  dfs(v, 0, -1, dist_from_v);

  int ans = 0;
  for(int i = 0; i < N; i++){
    if(dist_from_u[i] < dist_from_v[i]){
      ans = max(ans, dist_from_v[i] - 1);
    }
  }
  cout << ans << endl;
  
}
