#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
vector<int> g[N];
int n, x, y;
int f[N], dep[N];
void dfs(int u, int fa) {
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v == fa) continue;
    dep[v] = dep[u] + 1;
    dfs(v, u);
    f[u] = max(f[u], f[v] + 1);
  }
}
int main() {
  cin >> n >> x >> y;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(x, 0);
  cout << f[y] + dep[y] - dep[x] << endl;
  return 0;
}
