/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,u,v,dist[3][202020]; 
vi adj[202020];

void dfs(int s, int p, int c){
  for(auto t:adj[s]){
    if(t!=p){
      dist[c][t] = dist[c][s]+1;
      dfs(t, s, c);
    }
  }
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> u >> v;
  for(int i=1;i<n;i++){
    int x,y;
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
  }        
  dfs(u,-1,0);
  dfs(v,-1,1);
  int root = u;
  int d = dist[0][v];
  {
    int mx = -10000000;
    for(int i=1;i<=n;i++){
      int cur = dist[0][i]-dist[1][i];
      if(cur<0 && cur>mx ){
        root = i;
        mx = cur;
      }
    }
    int ans = dist[0][root];
    dfs(root, -1, 2);
    mx = 0;
    //cout << ans << " " << root << endl;
    for(int i=1;i<=n;i++){
      if(dist[0][i]<dist[1][i]){
        mx = max(mx, dist[2][i]);
      }
    }
    ans+=mx;
    if(d%2==0)ans++;
    cout << ans << endl;
  }

    

return 0;
}
///....
