#include <bits/stdc++.h>
using namespace std;
vector<int> G[100005];
int d[2][100005];
void dfs(int v, int p, int c) {
  for (int x : G[v]) {
    if (x == p) continue;
    d[c][x] = d[c][v] + 1;
    dfs(x, v, c);
  }
}
int main() {
  int n, s, t, a, b;
  scanf("%d%d%d", &n, &s, &t);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(s, s, 0);
  dfs(t, t, 1);
  int f = s;
  for (int i = 1; i <= n; i++) {
    if (d[1][i] > d[0][i] && d[0][i] > d[0][f]) f = i;
  }
  printf("%d\n", d[1][f] - 1);
  return 0;
}
