#include <bits/stdc++.h>
using namespace std;
using LL = long long;
class Edge {
 public:
  LL from, to, value;
  Edge() {}
  Edge(LL f, LL t, LL v) {
    from = f;
    to = t;
    value = v;
  }
};
std::vector<LL> dijkstra(int s, int N, vector<Edge> E) {
  std::vector<LL> ans(N, 1e9);
  std::vector<std::vector<Edge>> Edges(N);
  for (auto e : E) {
    Edges.at(e.from).push_back(e);
  }
  priority_queue<pair<LL, LL>, std::vector<pair<LL, LL>>, greater<pair<LL, LL>>>
      que;
  ans.at(s) = 0;
  que.push(make_pair(0, s));
  while (!que.empty()) {
    pair<LL, LL> p = que.top();
    que.pop();
    if (ans.at(p.second) < p.first) continue;
    for (int i = 0; i < Edges.at(p.second).size(); i++) {
      if (ans.at(p.second) + Edges.at(p.second).at(i).value <
          ans.at(Edges.at(p.second).at(i).to)) {
        ans.at(Edges.at(p.second).at(i).to) =
            ans.at(p.second) + Edges.at(p.second).at(i).value;
        que.push(make_pair(ans.at(Edges.at(p.second).at(i).to),
                           Edges.at(p.second).at(i).to));
      }
    }
  }
  return ans;
}
class UnionFind {
 public:
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool connect(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};
void solve(long long N, long long u, long long v, std::vector<long long> A,
           std::vector<long long> B) {
  vector<Edge> E;
  v--, u--;
  for (int i = 0; i < N - 1; i++) {
    A[i]--, B[i]--;
    E.push_back(Edge(A[i], B[i], 1));
    E.push_back(Edge(B[i], A[i], 1));
  }
  LL w = v, h = u;
  LL q = N;
  vector<LL> d1 = dijkstra(w, q, E);
  vector<LL> d2 = dijkstra(h, q, E);
  UnionFind Uni(N);
  for (int i = 0; i < N - 1; i++) {
    if (d1[A[i]] > 1 && d1[B[i]] > 1) {
      Uni.connect(A[i], B[i]);
    }
  }
  LL ans = 0;
  for (int i = 0; i < N; i++) {
    if (Uni.same(u, i)) {
      ans = max(ans, d1[i] - 1);
    }
  }
  cout << ans << endl;
  return;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long u;
  scanf("%lld", &u);
  long long v;
  scanf("%lld", &v);
  std::vector<long long> A(N - 1);
  std::vector<long long> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, u, v, std::move(A), std::move(B));
  return 0;
}
