#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
const int MAX = 1e5 + 9;
vector<vector<int>> G(MAX);
vector<int> dist(MAX, -1);
int ans = 0;
void dfs(int v, int p, int d) {
  for (int u : G[v]) {
    if (u == p) continue;
    dist[u] = d + 1;
    dfs(u, v, d + 1);
  }
}
void dfs2(int v, int p, int d) {
  for (int u : G[v]) {
    if (u == p) continue;
    if (dist[u] <= d + 1) {
      ans = max(ans, d + 1);
      continue;
    }
    ans = max(ans, dist[u] - 1);
    dfs2(u, v, d + 1);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, u, v;
  cin >> n >> u >> v;
  --u, --v;
  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[v] = 0;
  dfs(v, -1, 0);
  dfs2(u, -1, 0);
  cout << ans << endl;
  return 0;
}
