#include <bits/stdc++.h>
using namespace std;
bool used[100005];
vector<long long> node[100005];
long long T_dis[100005] = {0}, A_dis[100005] = {0};
void dfs_T(long long pos, long long dis) {
  T_dis[pos] = dis;
  for (int i = 0; i < node[pos].size(); i++) {
    long long to = node[pos][i];
    if (!used[to]) {
      used[to] = true;
      dfs_T(to, dis + 1);
    }
  }
}
void dfs_A(long long pos, long long dis) {
  A_dis[pos] = dis;
  for (int i = 0; i < node[pos].size(); i++) {
    long long to = node[pos][i];
    if (!used[to]) {
      used[to] = true;
      dfs_A(to, dis + 1);
    }
  }
}
void dfs_G(long long pos) {
  for (int i = 0; i < node[pos].size(); i++) {
    long long to = node[pos][i];
    if (!used[to] && T_dis[to] < A_dis[to]) {
      used[to] = true;
      dfs_G(to);
    }
  }
}
int main() {
  long long n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  for (int i = 0; i <= n; i++) used[i] = false;
  used[u] = true;
  dfs_T(u, 0);
  for (int i = 0; i <= n; i++) used[i] = false;
  used[v] = true;
  dfs_A(v, 0);
  for (int i = 0; i <= n; i++) used[i] = false;
  used[u] = true;
  dfs_G(u);
  long long ps = 0, max_v = -17441744;
  for (int i = 1; i <= n; i++) {
    if (used[i]) {
      if (T_dis[i] > max_v) {
        max_v = T_dis[i];
        ps = i;
      }
    }
  }
  long long sa = A_dis[ps] - T_dis[ps];
  long long ans = T_dis[ps];
  ans += sa - 1;
  cout << ans + 1 << endl;
}
