#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
int n, ru, rv;
vector<int> ck(N, 0);
int dic[N][2];
void dfs(int u, int q, int sum) {
  dic[u][q] = sum;
  ck[u] = 1 - q;
  for (int v : g[u]) {
    if (ck[v] == q) {
      dfs(v, q, sum + 1);
    }
  }
}
int ans = 0;
void sol(int u, int q, int sum) {
  ck[u] = 1 - q;
  for (int v : g[u]) {
    if (ck[v] == q)
      if (dic[v][1 - q] > sum + 1) {
        sol(v, q, sum + 1);
        ans = max(ans, min(dic[v][1 - q], sum + 1));
      } else if (dic[v][1 - q] == sum + 1)
        ans = max(ans, sum + 1);
  }
}
int main() {
  freopen("in.txt", "r", stdin);
  cin >> n >> ru >> rv;
  for (int i = 0; i + 1 < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(rv, 0, 0);
  sol(ru, 1, 0);
  cout << ans << endl;
}
