#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
vector<int> G[MAX];
int ans;
int dist[MAX];
void dfs(int n, int d) {
  dist[n] = d;
  for (int next : G[n]) {
    if (dist[next] == INF) dfs(next, d + 1);
  }
}
void dfs2(int n, int d) {
  if (dist[n] <= d) {
    ans = max(ans, dist[n]);
    return;
  }
  for (int next : G[n]) {
    dfs2(next, d + 1);
  }
}
int main() {
  int N, v, u;
  cin >> N >> v >> u;
  v--, u--;
  for (int i = 0; i < (N - 1); ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 0; i < (N); ++i) dist[i] = INF;
  dfs(u, 0);
  ans = 0;
  dfs2(v, 0);
  cout << ans << endl;
}
