#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  int T,A; cin>>T>>A;
  T--; A--;
  vii X(N);
  vi upA,downA;
  rep(i,0,N-1){
    int a,b; cin>>a>>b;
    if(a>b)
      swap(a,b);
    if(a!=A&&b!=A){
      X[a-1].push_back(b-1);
      X[b-1].push_back(a-1);
    }
    else if(a==A)
      downA.push_back(b-1);
    else if(b==A)
      upA.push_back(a-1);
  }
  int TA=-1;
  int count1=1,count2=1;
  stuck<int> Q;
  vector<bool> F(N,1);
  rep(i,0,upA.size()){
    Q.push(upA[i]);
    F[upA[i]]=0;
    if(upA[i]==T)
      TA=1;
  }
  F[A]=0;
  Q.push(-1);
  int memo=A;
  while(1){
    count1++;
    int K=Q.front();
    Q.pop();
    if(K==-1)
      count1=1;
    else{
      rep(i,0,X[K].size()){
        if(F[X[K][i]]){
          Q.push(X[K][i]);
          F[X[K][i]]=0;
        }
      }
      if(A==K){
        TA=count1;
        break;
      }
    }
    if(Q.size()==0)
      break;
  }
  if(TA==-1){
  count1=1;
  stuck<int> QA;
  vector<bool> FA(N,1);
  rep(i,0,downA.size()){
    Q.push(downA[i]);
    F[downA[i]]=0;
    if(downA[i]==T)
      TA=1;
  }
  FA[A]=0;
  QA.push(-1);
  int memo=A;
  while(1){
    count1++;
    int K=QA.front();
    QA.pop();
    if(K==-1)
      count1=1;
    else{
      rep(i,0,X[K].size()){
        if(FA[X[K][i]]){
          QA.push(X[K][i]);
          FA[X[K][i]]=0;
        }
      }
      if(A==K){
        TA=count1;
        break;
      }
    }
    if(Q.size()==0)
      break;
  }
    queue<int> Z;
  vector<bool> P(N,1);
  vector<bool> PP(N,1);
  queue<int> QQ;
        QQ.push(T);
    PP[T]=0;
        QQ.push(-1);
        int count=0;
        while(1){
          int k=QQ.front();
          QQ.pop();
          if(k==-1){
            count++;
            if(count==(TA+1)/2)
              break;
          }
          else{
            P[k]=0;
            rep(i,0,X[k].size()){
              if(PP[X[k][i]]){
                QQ.push(X[K][i]);
                PP[X[k][i]]=0;
              }
            }
          }
        }
  rep(i,0,upA.size()){
    Z.push(upA[i]);
    P[upA[i]]=0;
    if(upA[i]==T)
      TA=1;
  }
  P[A]=0;
  Z.push(-1);
  memo=A;
  while(1){
    int K=Z.front();
    Z.pop();
    if(K==memo)
      break;
    if(K==-1){
      Z.push(-1);
      count2++;
    }
    else{
      rep(i,0,X[K].size()){
        if(P[X[K][i]]){
          Z.push(X[K][i]);
          P[X[K][i]]=0;
        }
      }
    }
    memo=K;
  }
  }
  else{
  queue<int> Z;
  vector<bool> P(N,1);
  vector<bool> PP(N,1);
  queue<int> QQ;
        QQ.push(T);
    PP[T]=0;
        QQ.push(-1);
        int count=0;
        while(1){
          int k=QQ.front();
          QQ.pop();
          if(k==-1){
            count++;
            if(count==(TA+1)/2)
              break;
          }
          else{
            P[k]=0;
            rep(i,0,X[k].size()){
              if(PP[X[k][i]]){
                QQ.push(X[K][i]);
                PP[X[k][i]]=0;
              }
            }
          }
        }
  rep(i,0,downA.size()){
    Z.push(downA[i]);
    P[downA[i]]=0;
    if(downA[i]==T)
      TA=1;
  }
  P[A]=0;
  Z.push(-1);
  memo=A;
  while(1){
    int K=Z.front();
    Z.pop();
    if(K==memo)
      break;
    if(K==-1){
      Z.push(-1);
      count2++;
    }
    else{
      rep(i,0,X[K].size()){
        if(P[X[K][i]]){
          Z.push(X[K][i]);
          P[X[K][i]]=0;
        }
      }
    }
    memo=K;
  }
  }
  ifg(TA%2==1)
    count2--;
  cout<<count2<<endl;
  }

