#include <bits/stdc++.h>
using namespace std;
int n, t, a;
struct edge {
  int v;
  edge *next;
} * h[233333], pool[233333];
int top;
inline void addedge(int u, int v) {
  edge *tmp = &pool[top++];
  tmp->v = v;
  tmp->next = h[u];
  h[u] = tmp;
  edge *pmt = &pool[top++];
  pmt->v = u;
  pmt->next = h[v];
  h[v] = pmt;
}
int vis[233333], pa[233333], dep[233333], maxdep[233333];
void dfs(int u) {
  vis[u] = 1;
  for (edge *tmp = h[u]; tmp; tmp = tmp->next) {
    if (!vis[tmp->v]) {
      pa[tmp->v] = u;
      dep[tmp->v] = dep[u] + 1;
      dfs(tmp->v);
      maxdep[u] = max(maxdep[tmp->v] + 1, maxdep[u]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int u, v;
  cin >> n >> t >> a;
  for (int i = 1; i < n; i++) cin >> u >> v, addedge(u, v);
  dfs(a);
  int cur = t;
  while (dep[cur] * 2 > dep[t]) cur = pa[cur];
  cout << dep[cur] + maxdep[cur] - 1 << endl;
  return 0;
}
