#include <bits/stdc++.h>
using namespace std;
int n;
int u, v;
int ans;
vector<int> ne[100005];
int disu[100005], disv[100005];
bool vis1[100005], vis2[100005], vis3[100005];
void dfs1(int x, int d) {
  vis1[x] = true;
  disu[x] = d;
  for (int i = 0; i < ne[x].size(); i++) {
    if (!vis1[ne[x][i]]) {
      dfs1(ne[x][i], d + 1);
    }
  }
}
void dfs2(int x, int d) {
  vis2[x] = true;
  disv[x] = d;
  for (int i = 0; i < ne[x].size(); i++) {
    if (!vis2[ne[x][i]]) {
      dfs2(ne[x][i], d + 1);
    }
  }
}
void dfs3(int x) {
  vis3[x] = true;
  if (disv[x] <= disu[x]) return;
  if (disv[x] % 2 == disu[x] % 2) {
    ans = max(ans, disv[x]);
  } else {
    ans = max(ans, disv[x] - 1);
  }
  for (int i = 0; i < ne[x].size(); i++) {
    if (!vis3[ne[x][i]]) {
      dfs3(ne[x][i]);
    }
  }
}
int main() {
  cin >> n;
  cin >> u >> v;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    ne[a].push_back(b);
    ne[b].push_back(a);
  }
  dfs1(u, 0);
  dfs2(v, 0);
  if (disu[v] <= 2 && ne[u].size() == 1) {
    cout << 1 << endl;
    return 0;
  }
  dfs3(u);
  cout << ans << endl;
}
