#include <bits/stdc++.h>
using namespace std;
int node, tx, ax, acost[100005], tcost[100005];
bool vis[100005];
vector<int> graph[100005];
void bfs(int sx) {
  memset(vis, 0, sizeof(vis));
  acost[sx] = 0;
  vis[sx] = 1;
  queue<int> q;
  q.push(sx);
  while (q.size() > 0) {
    int xx = q.front();
    q.pop();
    for (int i = 0; i < graph[xx].size(); i++) {
      int yy = graph[xx][i];
      if (!vis[yy]) {
        acost[yy] = 1 + acost[xx];
        vis[yy] = 1;
        q.push(yy);
      }
    }
  }
  return;
}
void bfs2(int sx) {
  memset(vis, 0, sizeof(vis));
  vis[sx] = 1;
  tcost[sx] = 0;
  queue<int> q;
  q.push(sx);
  while (q.size() > 0) {
    int xx = q.front();
    q.pop();
    for (int i = 0; i < graph[xx].size(); i++) {
      int yy = graph[xx][i];
      if (!vis[yy]) {
        tcost[yy] = 1 + tcost[xx];
        vis[yy] = 1;
        q.push(yy);
      }
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int x, y;
  cin >> node >> tx >> ax;
  for (int i = 1; i < node; i++) {
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  int ans = 1;
  bfs(ax);
  bfs2(tx);
  for (int i = 1; i <= node; i++) {
    if (tcost[i] < acost[i]) {
      ans = max(ans, tcost[i]);
      ans = max(ans, tcost[i] * 2);
    }
  }
  cout << ans << endl;
  return 0;
}
