#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100005];
int dis1[100005], dis2[100005];
void dfs(int u, int fa, int val, int tag) {
  if (tag == 1) dis1[u] = val;
  if (tag == 2) dis2[u] = val;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (v == fa) continue;
    dfs(v, u, val + 1, tag);
  }
}
int main() {
  int n, start, end, num = 0;
  cin >> n >> start >> end;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  dfs(end, -1, 0, 1);
  int mx = 0, pos = end;
  for (int i = 1; i <= n; i++) {
    if (mx < dis1[i]) {
      mx = dis1[i];
      pos = i;
    }
  }
  dfs(start, -1, 0, 2);
  if (dis2[pos] < mx) {
    cout << mx - 1 << endl;
    return 0;
  }
  int val = dis1[start];
  while (val) {
    val--;
    if (val == 0) break;
    val--;
    num++;
    if (val == 0) break;
    val++;
    val--;
    num++;
  }
  cout << num << endl;
}
