#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
vector<int> g[100005];
int d[100005], e[100005];
void dfs(int x, int p) {
  d[x] = d[p] + 1;
  for (int i : g[x])
    if (i != p) dfs(i, x);
}
void dfs2(int x, int p) {
  e[x] = e[p] + 1;
  for (int i : g[x])
    if (i != p && e[x] + 1 < d[i]) dfs2(i, x);
}
int main() {
  ios::sync_with_stdio(false);
  int n, u, v, x, y, z = 0;
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++)
    cin >> x >> y, g[x].push_back(y), g[y].push_back(x);
  dfs(v, v);
  dfs2(u, u);
  for (int i = 1; i <= n; i++) z = max(z, e[i]);
  if (d[u] % 2 == 0) z--;
  cout << z;
}
