#include <bits/stdc++.h>
using namespace std;
int n, a, b, maxdep, depth[100010], check[100010], parent[100010];
vector<int> v[100010];
void dfs(int x, int d) {
  depth[x] = d;
  check[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (!check[v[x][i]]) {
      parent[v[x][i]] = x;
      dfs(v[x][i], d + 1);
    }
  }
}
void dfs2(int x) {
  check[x] = 2;
  maxdep = max(maxdep, depth[x]);
  for (int i = 0; i < v[x].size(); i++) {
    if (check[v[x][i]] != 2) {
      dfs2(v[x][i]);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(b, 0);
  int u = a;
  while (depth[u] - 1 > depth[a] - depth[u] + 1) {
    u = parent[u];
  }
  dfs2(u);
  printf("%d", maxdep - 1);
}
