#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0, b = getchar(), c = 1;
  while (!isdigit(b)) c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b)) a = a * 10 + b - '0', b = getchar();
  return a * c;
}
int n, s, t, ans, d[100005], f[100005], si[100005];
vector<int> g[100005];
void dfs(int x, int y, int z) {
  d[x] = z, f[x] = y, si[x] = 1;
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != y)
      dfs(g[x][i], x, z + 1), si[x] = max(si[x], si[g[x][i]] + 1);
}
int main() {
  n = read(), s = read(), t = read();
  swap(s, t);
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    g[x].push_back(y), g[y].push_back(x);
  }
  dfs(s, 0, 0);
  for (int i = 1; i <= n; i++) {
    if (d[i] > d[t] - d[i]) ans = max(ans, si[i] + d[i] - 2);
  }
  cout << ans;
  return 0;
}
