#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define mod 1000000007
typedef long long ll;
using namespace std;

const int MAX = 100005;
vector<int> G[MAX];
int D[MAX][2];
void dfs(int cur, int pre, int d, int id){
  D[cur][id] = d;
  for(int v:G[cur]){
    if(v==pre) continue;
    dfs(v,cur,d+1,id);
  }
}

int main(){
  int n,s,t;
  cin >> n >> s >> t;
  s--; t--;
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  dfs(s,-1,0,0);
  dfs(t,-1,0,1);

  int mx = 0;
  for(int i=0;i<n;i++){
    if(D[i][0] < D[i][1]) mx = max(mx,D[i][1]);
  }

  cout << mx - 1 << endl;
  return 0;
}