#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
vector<int> g[100100];
int dist[100100] = {};
int ans[100100] = {};
int tak, ao;
void dfs(int u, int pa, int d) {
  for (auto v : g[u]) {
    if (v == pa) continue;
    dfs(v, u, d + 1);
  }
  dist[u] = d;
}
void dfs2(int u, int pa, int d) {
  for (auto v : g[u]) {
    if (v == u) continue;
    if (d + 1 >= dist[v]) {
      continue;
    } else {
      dfs2(v, u, d + 1);
    }
  }
  ans[u] = dist[u];
}
int main() {
  int N;
  cin >> N >> tak >> ao;
  tak--;
  ao--;
  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);
  }
  dfs(ao, -1, 0);
  dfs2(tak, -1, 0);
  int f_a = 0;
  for (int i = 0; i < N; i++) {
    f_a = max(ans[i], f_a);
  }
  cout << f_a - 1 << endl;
}
