#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
using Graph = vector<vector<int>>;
Graph G;
vector<int> A, T;
void dfs1(int v, int p, int d) {
  A[v] = d;
  for (auto nv : G[v]) {
    if (nv == p) continue;
    dfs1(nv, v, d + 1);
  }
}
void dfs2(int v, int p, int d) {
  T[v] = d;
  for (auto nv : G[v]) {
    if (nv == p) continue;
    dfs2(nv, v, d + 1);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  G.assign(n, vector<int>());
  for (int i = 0; i < (int)(n - 1); i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  A.resize(n, INF);
  T.resize(n, INF);
  dfs1(v - 1, -1, 0);
  dfs2(u - 1, -1, 0);
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (T[i] <= A[i]) chmax(ans, A[i] - (A[i] % 2 != T[i] % 2));
  }
  cout << ans << endl;
}
