#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
struct edge {
  long long int to;
  long long int cost;
};
vector<vector<edge>> G;
int N, u, v, ans = 0;
vector<int> adist;
void dfs(int pos, int depth) {
  adist[pos] = depth;
  for (int i = 0; i < G[pos].size(); i++) {
    if (adist[G[pos][i].to] != -1) continue;
    dfs(G[pos][i].to, depth + 1);
  }
}
void dfs2(int pos, int depth) {
  {
    for (int i = 0; i < G[pos].size(); i++) {
      if (depth >= adist[G[pos][i].to]) {
        ans = max(ans, depth);
        continue;
      }
      dfs2(G[pos][i].to, depth + 1);
    }
  }
}
int main() {
  cin >> N >> u >> v;
  G = vector<vector<edge>>(N + 1);
  adist = vector<int>(N + 1, -1);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
  }
  dfs(v, 0);
  dfs2(u, 0);
  cout << ans << endl;
}
