#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
Graph g;
vector<int> dist;
vector<bool> seen;
void dfs(int v, int d) {
  seen[v] = true;
  dist[v] = d;
  for (auto nv : g[v]) {
    if (!seen[nv]) dfs(nv, d + 1);
  }
}
int ans = 0;
void escape(int v, int d) {
  ans = max(ans, d);
  for (auto nv : g[v]) {
    if (dist[nv] > d + 1) {
      escape(nv, d + 1);
    } else if (dist[nv] == d + 1) {
      ans = max(ans, d + 1);
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  v--;
  u--;
  g.resize(n);
  for (int i = (0); i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dist.resize(n);
  seen.resize(n);
  fill((dist).begin(), (dist).end(), 0);
  fill((seen).begin(), (seen).end(), false);
  dfs(v, 0);
  escape(u, 0);
  cout << ans << endl;
}
