#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chmax(T& ans, T t) {
  if (t > ans) ans = t;
}
template <class T>
inline void chmin(T& ans, T t) {
  if (t < ans) ans = t;
}
int disT[100010];
int disA[100010];
void dfs(int now, vector<bool>& visited, vector<vector<int>>& G, bool flag) {
  for (auto it : G[now]) {
    if (!visited[it]) {
      if (flag) {
        disT[it] = disT[now] + 1;
        visited[now] = true;
        dfs(it, visited, G, flag);
      } else {
        disA[it] = disA[now] + 1;
        visited[now] = true;
        dfs(it, visited, G, flag);
      }
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  vector<vector<int>> G(n);
  for (long long i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[b].push_back(a);
    G[a].push_back(b);
  }
  vector<bool> visited(n), visitedb(n);
  dfs(u, visited, G, true);
  dfs(v, visitedb, G, false);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (disA[i] <= disT[i]) {
      ans = max((disT[i] - disA[i]) / 2, ans);
    } else {
      auto t = disA[i] - disT[i];
      t /= 2;
      ans = max(disT[i] + t, ans);
    }
  }
  cout << ans << endl;
}
