#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int n;
vector<int> adj[100005];

vector<int> dist;
void dfs(int v, int d = 0, int p = -1) {
  dist[v] = d;
  for (int u : adj[v]) {
    if (u == p)
      continue;
    dfs(u, d + 1, v);
  }
}
vector<int> calcDist (int v) {
  dist = vector<int>(n);
  dfs(v);
  return dist;
}

int main() {
  int u, v;
  cin >> n >> u >> v;
  u--; v--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  vector<int> distU = calcDist(u);
  vector<int> distV = calcDist(v);
  
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (distU[i] < distV[i])
      m = max(m, distV[i]);
  }
  m--;
  cout << m << endl;
  return 0;
}