#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


class DIJKSTRA {

  typedef long long ll;
  typedef std::pair<ll,ll> P;
  struct Edge { ll to; ll cost; };

  private:
    std::vector<std::vector<Edge>> G; // j-th Edge connected with vertex i : G[i][j]
    std::vector<ll> D;  // result
    std::vector<ll> C;  // # of paths
    bool directed;

  public:
    DIJKSTRA ( ll N , bool dir = false ) : directed (dir) {
      G.resize(N);
      D.assign(N, std::numeric_limits<ll>::max());
      C.assign(N, 0);
    }

    void Path ( ll i, ll j, ll x ) {
      G[i].push_back( {j,x} );
      if ( !directed ) G[j].push_back( {i,x} );
    }

    void Run (ll start) {
      std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
      pq.push( P(0, start) );
      D[start] = 0;
      C[start] = 1;
      while( !pq.empty() ) {
        auto cur = pq.top(); pq.pop();
        int d = cur.first;
        int v = cur.second;
        if ( D[v] < d ) continue;
        for(auto&& e : G[v]) {
          if ( D[e.to] > D[v] + e.cost ) {
            D[e.to] = D[v] + e.cost;
            pq.push( P(D[e.to], e.to) );
            C[e.to] = C[v];
          }
          else if ( D[e.to] == D[v] + e.cost ) C[e.to] += C[v];
        }
      }
      return;
    }

    ll Get ( ll i ){ return D[i]; }

    ll GetPaths ( ll i ) { return C[i]; }
};


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, u, v; std::cin >> N >> u >> v; u--, v--;
  std::vector<int> E(N), C(N);
  std::vector<std::vector<int>> G(N);
  rep(i,N-1) {
    int A, B; std::cin >> A >> B; A--,B--;
    G[A].push_back(B);
  }

  {
    DIJKSTRA dij(N);
    rep(i,N) for(auto&& e : G[i]) dij.Path(i,e,1);
    dij.Run(u);
    rep(i,N) E[i] = dij.Get(i);
  }
  {
    DIJKSTRA dij(N);
    rep(i,N) for(auto&& e : G[i]) dij.Path(i,e,1);
    dij.Run(v);
    rep(i,N) C[i] = dij.Get(i);
  }

  int dcmax = -1;
  for(int i=0; i<N; i++) {
    if ( E[i] < C[i] ) dcmax = std::max(dcmax, C[i]);
  }
  std::cout << dcmax - 1 << std::endl;
  return 0;
}


Measured memory_bytes: 14976