#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  int num = 0, flus = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') flus = -flus;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    num = num * 10 + ch - '0';
    ch = getchar();
  }
  return num * flus;
}
const int MAXN = 2e5 + 2e2;
struct node {
  int nxt, to;
};
node edge[MAXN];
int head[MAXN];
int depth[MAXN];
int Max[MAXN];
int n, s, t, maxn, tot;
void addedge(int u, int v) {
  edge[++tot].nxt = head[u];
  edge[tot].to = v;
  head[u] = tot;
  return;
}
void dfs(int u, int last) {
  Max[u] = depth[u] = depth[last] + 1;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v != last) {
      dfs(v, u);
      Max[u] = max(Max[u], Max[v]);
    }
  }
  return;
}
int Dfs(int u, int now, int last) {
  if (now >= depth[u]) return 0;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (!Dfs(v, now + 1, u) && v != last) maxn = u;
  }
  return 1;
}
void DFS() {
  dfs(t, 0);
  Dfs(s, 0, 0);
  return;
}
int main(void) {
  scanf("%d%d%d", &n, &s, &t);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  DFS();
  printf("%d\n", Max[maxn] - 2);
  return 0;
}
