#include <bits/stdc++.h>
const long long int mod = 1e9 + 7;
const long long int inf = LLONG_MAX;
using namespace std;
long long int power_mod(long long int x, long long int y, long long int p) {
  long long int ans = 1;
  x = x % p;
  if (x == 0) return p;
  while (y > 0) {
    if (y & 1) {
      ans = (ans * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return ans;
}
const int n = 200005;
int distt[n], dista[n];
vector<int> adj[n];
void calc_t(int v, int p) {
  if (p == -1) {
    distt[v] = 0;
  } else
    distt[v] = distt[p] + 1;
  int i;
  for (i = 0; i < adj[v].size(); i++) {
    if (adj[v][i] == p) continue;
    calc_t(adj[v][i], v);
  }
}
void calc_a(int v, int p) {
  if (p == -1) {
    dista[v] = 0;
  } else
    dista[v] = dista[p] + 1;
  int i;
  for (i = 0; i < adj[v].size(); i++) {
    if (adj[v][i] == p) continue;
    calc_a(adj[v][i], v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, k, l, m, n, u, v;
  cin >> n >> u >> v;
  for (i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  calc_t(u - 1, -1);
  calc_a(v - 1, -1);
  if (distt[v - 1] == 2 && adj[u - 1].size() == 1) {
    cout << 1;
    return 0;
  }
  int maxcount = 0;
  for (i = 0; i < n; i++) {
    int temp = dista[i] - distt[i] - 1;
    maxcount = max(maxcount, temp);
  }
  cout << maxcount;
  return 0;
}
