#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
const int INF = (int)1e9;
const long long IINF = 1LL << 62;
const int maxn = 10000005;
vector<int> adj[100005];
int dist1[100005];
int dist2[100005];
void dfs(int node, int par, int dist1[]) {
  for (int child : adj[node]) {
    if (child == par) continue;
    dist1[child] = dist1[node] + 1;
    dfs(child, node, dist1);
  }
}
int main() {
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dist1[t] = 0;
  dfs(t, -1, dist1);
  dist2[a] = 0;
  dfs(a, -1, dist2);
  int res = (dist1[t]) / 2;
  for (int i = 1; i <= n; i++) {
    if (i != t && i != a) {
      if (dist1[i] < dist2[i]) {
        res = max(dist2[i] - 1, res);
      }
    }
  }
  cout << res;
}
