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

const int N = 1e5 + 10;
vector<int> g[N];

int dist[N][2];

void dfs(int s, int p, int type){
   dist[s][type] = dist[p][type] + 1;
   for(auto i: g[s]){
      if(i != p){
         dfs(i, s, type);
      }
   }
}

int main(){

   int n, u, v;
   cin >> n >> u >> v;

   for (int i = 0; i < n-1; ++i)
   {
      int x, y;
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
   }

   dfs(u, 0, 0);
   dfs(v, 0, 1);

   int ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      if(dist[i][0] < dist[i][1])
         ans = max(ans, dist[i][1] - 2);
   }

   cout<<ans;
   return 0;
}
