#include <bits/stdc++.h>
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace {
struct INIT {
  INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} INIT;
}  // namespace
using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(void) {}
  Edge(int src, int dst) : src(src), dst(dst) {}
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
void edges_to_graph(Graph &graph, const Edges &edges, const int vertices,
                    const bool directed = true) {
  graph.clear(), graph.resize(vertices);
  for (const auto &e : edges) graph[e.src].emplace_back(e);
  if (!directed)
    for (const auto &e : edges)
      graph[e.dst].emplace_back(Edge(e.dst, e.src, e.weight));
}
void dfs(Graph &g, int v, int p, int u, vector<int> &route, bool &goal) {
  route.push_back(v);
  if (v == u) {
    goal = true;
    return;
  }
  for (const auto &e : g[v]) {
    if (e.dst == p) continue;
    dfs(g, e.dst, v, u, route, goal);
    if (goal) return;
  }
  route.pop_back();
}
void dfs2(Graph &g, int v, int p, int cnt, int &maxi) {
  maxi = max(maxi, cnt);
  for (const auto &e : g[v]) {
    if (e.dst == p) continue;
    dfs2(g, e.dst, v, cnt + 1, maxi);
  }
}
Graph graph;
int main(void) {
  int n, u, v;
  cin >> n >> u >> v;
  --u, --v;
  Edges edges(n - 1);
  vector<int> ab(n);
  for (int i = 0; i < (int)(n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    edges[i] = {--a, --b};
  }
  edges_to_graph(graph, edges, n, false);
  vector<int> route;
  bool goal = false;
  dfs(graph, v, -1, u, route, goal);
  int cnt = route.size() / 2 - 1;
  int k = route.size() - (cnt + 1);
  int newv = route[k];
  int newp = route[k - 1];
  int maxi = 0;
  dfs2(graph, newv, newp, cnt, maxi);
  if (route.size() & 1) maxi = max(maxi, cnt + 1);
  cout << maxi << endl;
  return 0;
}
