#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int tak, aok;
long long dt[MAXN], du[MAXN];
set<int> s;
vector<int> g[MAXN];
void bfs1(int u) {
  queue<int> q;
  memset(dt, -1, sizeof(dt));
  q.push(u);
  dt[u] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto &k : g[u]) {
      if ((s.find(k) == s.end()) and dt[k] == -1) {
        q.push(k);
        dt[k] = dt[u] + 1;
      }
    }
  }
}
void bfs2(int u) {
  queue<int> q;
  memset(du, -1, sizeof(du));
  q.push(u);
  du[u] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto &k : g[u]) {
      if (du[k] == -1) {
        q.push(k);
        du[k] = du[u] + 1;
      }
    }
  }
}
int main() {
  int n;
  cin >> n >> tak >> aok;
  s.insert(aok);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    if (v == aok) s.insert(u);
    if (u == aok) s.insert(v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  bfs1(tak);
  bfs2(aok);
  long long ans = 0;
  int maxi = 1e9;
  int eq = -1;
  for (int i = 1; i <= n; i++) {
    if (dt[i] != -1 and dt[i] < du[i]) {
      ans = max(ans, du[i]) - 1;
    }
  }
  cout << ans;
}
