#include <bits/stdc++.h>
using namespace std;
int n, u, v;
vector<int> e[100015];
void dfs(int dep, int pre, int cur, int node[]) {
  for (int i = 0; i < e[cur].size(); i++) {
    if (node[e[cur][i]] == 0 && e[cur][i] != pre) {
      node[e[cur][i]] = dep + 1;
      dfs(dep + 1, cur, e[cur][i], node);
    }
  }
}
int main(void) {
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  int u_dist[100015], v_dist[100015];
  u_dist[u] = 0;
  dfs(0, u, u, u_dist);
  v_dist[v] = 0;
  dfs(0, v, v, v_dist);
  int ma = -1;
  for (int i = 1; i <= n; i++) {
    if (u_dist[i] < v_dist[i]) {
      ma = max(ma, v_dist[i] - 1);
    }
  }
  cout << ma << endl;
}
