#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long INF = 1e18;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int LIMIT = 1e6 + 1;
vector<long long> FacMod(LIMIT), InvMod(LIMIT), FacInvMod(LIMIT);
const int dpComTableLIMIT = 3e3 + 1;
vector<vector<long long>> Com(dpComTableLIMIT,
                              vector<long long>(dpComTableLIMIT, 0));
const int ComKTableLIMIT = 1e7;
vector<long long> ComK(ComKTableLIMIT);
void DPComInit() {
  for (int i = 0; i < dpComTableLIMIT; i++) {
    Com[i][0] = 1;
  }
  for (int i = 1; i < dpComTableLIMIT; i++) {
    for (int j = 1; j < dpComTableLIMIT; j++) {
      Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
    }
  }
}
void ComKInit(long long N) {
  for (int i = 0; i <= ComKTableLIMIT; i++) {
    if (0 < i && i <= N / 2) {
      ComK[i] = (ComK[i - 1] * (N - i + 1) / i) % MOD;
    } else if (i == 0) {
      ComK[i] = 1;
    } else if (N / 2 < i && i <= N) {
      ComK[i] = ComK[N - i];
    } else {
      ComK[i] = -1;
    }
  }
}
void ComInit() {
  FacMod[0] = FacMod[1] = 1;
  InvMod[0] = 0;
  InvMod[1] = 1;
  FacInvMod[0] = FacInvMod[1] = 1;
  for (int i = 2; i < LIMIT; i++) {
    FacMod[i] = FacMod[i - 1] * i % MOD;
    InvMod[i] = -InvMod[MOD % i] * (MOD / i) % MOD + MOD;
    FacInvMod[i] = FacInvMod[i - 1] * InvMod[i] % MOD;
  }
}
long long ComMod(int n, int k) {
  if (n >= 0 && k >= 0 && n >= k) {
    return FacMod[n] * (FacInvMod[k] * FacInvMod[n - k] % MOD) % MOD;
  } else {
    return 0;
  }
}
long long power(long long x, long long y) {
  if (y < 0) {
    return 0;
  } else if (y == 0) {
    return 1LL;
  } else if (y % 2 == 0) {
    return power(x, y / 2) * power(x, y / 2);
  } else {
    return power(x, y - 1) * x;
  }
}
long long mpower(long long x, long long y, long long m) {
  if (y < 0) {
    return 0;
  } else if (y == 0) {
    return 1LL;
  } else if (y % 2 == 0) {
    return mpower(x, y / 2, m) * mpower(x, y / 2, m) % m;
  } else {
    return mpower(x, y - 1, m) * x % m;
  }
}
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return (a / GCD(a, b)) * b; }
pair<map<long long, long long>, bool> PrimeFactorization(long long N) {
  pair<map<long long, long long>, bool> ret;
  ret.second = true;
  if (N != 2) {
    while (N % 2 == 0) {
      N /= 2;
      ret.first[2]++;
      ret.second = false;
    }
  }
  for (long long i = 3; i * i <= N; i += 2) {
    while (N % i == 0) {
      N /= i;
      ret.first[i]++;
      ret.second = false;
    }
  }
  if (N != 1) {
    ret.first[N]++;
  }
  return ret;
}
bool compare_by_second(pair<long long, long long> a,
                       pair<long long, long long> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n, -1) {}
  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  int size(int x) { return -par[root(x)]; }
};
bool isOK(long long condition) { return true; }
long long binary_search() {
  long long ok = 1e18;
  long long ng = -1;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (isOK(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<vector<long long>> graph(N);
  for (int i = 0; i < N - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<long long> dist(N, INF);
  vector<bool> isSearched(N, false);
  function<void(long long)> dfs = [&](long long now) {
    if (isSearched[now]) return;
    isSearched[now] = true;
    for (long long to : graph[now]) {
      dist[to] = min(dist[to], dist[now] + 1);
      dfs(to);
    }
  };
  dist[u] = 0;
  dfs(u);
  vector<long long> taka = dist;
  dist.assign(N, INF);
  isSearched.assign(N, false);
  dist[v] = 0;
  dfs(v);
  vector<long long> aoki = dist;
  long long ans = 0;
  long long am = 0;
  for (int i = 0; i < N; i++) {
    if (taka[i] < aoki[i] && aoki[i] >= am) {
      am = aoki[i];
      ans = max(ans, taka[i] + (aoki[i] - taka[i]) / 2);
    }
  }
  cout << ans << endl;
  return 0;
}
