#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 10;
vector<int> adj[MAXN];
vector<int> par(MAXN);
vector<int> dis(MAXN);
vector<int> depth(MAXN);
vector<bool> vis(MAXN);
void bfs(int s) {
  queue<int> q;
  q.push(s);
  vis[s] = true;
  while (!q.empty()) {
    s = q.front();
    q.pop();
    for (auto i : adj[s]) {
      if (!vis[i]) {
        vis[i] = true;
        dis[i] = dis[s] + 1;
        par[i] = s;
        q.push(i);
      }
    }
  }
}
void findDepth(int r) {
  if (adj[r].size() == 0) {
    depth[r] = 1;
    return;
  }
  for (auto j : adj[r]) {
    findDepth(j);
    depth[r] = max(depth[r], depth[j]);
  }
  depth[r]++;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  bfs(v);
  for (int i = 1; i <= n; i++) {
    adj[i].clear();
  }
  for (int i = 1; i <= n; i++) {
    if (i == v) continue;
    adj[par[i]].push_back(i);
  }
  findDepth(v);
  if (u == v) {
    cout << 0 << '\n';
    return 0;
  }
  int move = max(0, (dis[u] - 3) / 3 + 1);
  if (dis[u] < 3) move = 0;
  for (int i = 0; i < move; i++) {
    u = par[u];
  }
  if (dis[u] & 1) {
    v = par[u];
  } else {
    v = par[par[u]];
  }
  int ans = move;
  if (dis[u] & 1)
    ans += depth[u] - 1;
  else {
    ans += depth[u];
  }
  cout << ans << '\n';
  return 0;
}
