#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
      to = x;
      return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
struct DoublingLowestCommonAncestor {
    const int LOG;
    vector< int > dep;
    const G &g;
    vector< vector< int > > table;

    DoublingLowestCommonAncestor(const G &g) : g(g), dep(g.size()), LOG(32 - __builtin_clz(g.size())) {
      table.assign(LOG, vector< int >(g.size(), -1));
    }

    void dfs(int idx, int par, int d) {
      table[0][idx] = par;
      dep[idx] = d;
      for(auto &to : g[idx]) {
        if(to != par) dfs(to, idx, d + 1);
      }
    }

    void build() {
      dfs(0, -1, 0);
      for(int k = 0; k + 1 < LOG; k++) {
        for(int i = 0; i < table[k].size(); i++) {
          if(table[k][i] == -1) table[k + 1][i] = -1;
          else table[k + 1][i] = table[k][table[k][i]];
        }
      }
    }

    int query(int u, int v) {
      if(dep[u] > dep[v]) swap(u, v);
      for(int i = LOG - 1; i >= 0; i--) {
        if(((dep[v] - dep[u]) >> i) & 1) v = table[i][v];
      }
      if(u == v) return u;
      for(int i = LOG - 1; i >= 0; i--) {
        if(table[i][u] != table[i][v]) {
          u = table[i][u];
          v = table[i][v];
        }
      }
      return table[0][u];
    }
};

vector<int> p, dist;
void dfs(int now, int prev, int d, const UnWeightedGraph &g) {
  dist[now] = d;
  p[now] = prev;
  REP(i, SZ(g[now])) {
    int nxt = g[now][i];
    if(nxt == prev) continue;
    dfs(nxt, now, d+1, g);
  }
}

int dfs2(int now, int prev, int ao, const UnWeightedGraph &g) {
  if(now == ao) return -1;
  int res = 0;
  REP(i, SZ(g[now])) {
    int nxt = g[now][i];
    if(nxt == prev) continue;
    chmax(res, dfs2(nxt, now, ao, g)+1);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  int ta, ao; cin >> ta >> ao;
  ta--; ao--;

  UnWeightedGraph g(n);
  REP(i, n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  p.resize(n, 0);
  dist.resize(n, 0);
  dfs(ta, -1, 0, g);

  ll r = ao;
  ll mid = ao;
  REP(i, dist[ao] - (dist[ao]-1)/2) {
    mid = r;
    r = p[r];
  }

  int ans = dfs2(r, -1, mid, g);

  ans += (dist[ao]-1) / 2;

  cout << max(ans + (dist[ao] % 2 == 0), dist[ao]/2) << endl;


}


Measured memory_bytes: 12288