#include <bits/stdc++.h>
using namespace std;
vector<int> v[100100], v1;
long long n, s, f, a, b, nd;
void dfs(int x, int pre, int r) {
  v1.push_back(x);
  if (x == s) {
    nd = r - 1;
    return;
  }
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i] != pre) {
      dfs(v[x][i], x, r + 1);
      if (v1[v1.size() - 1] == s) return;
    }
  v1.erase(v1.begin() + v1.size() - 1, v1.begin() + v1.size());
  return;
}
int dfs1(int x, int pre, int k, int r) {
  if (v[x].size() == 1 && v[x][0] == pre) return r;
  int g = 0;
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i] != pre && v[x][i] != k) g = max(dfs1(v[x][i], x, k, r + 1), g);
  return g;
}
int main() {
  cin >> n >> f >> s;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(f, -1, 0);
  if (nd % 2 == 0)
    cout << dfs1(v1[v1.size() / 2 - 1], -1, v1[v1.size() / 2], 0) + (nd / 2);
  else
    cout << dfs1(v1[v1.size() / 2 + 1], -1, v1[v1.size() / 2], 0) + nd / 2 + 1;
}
