#include <bits/stdc++.h>
using namespace std;
int dist(vector<vector<int>> &vec, int dest, int curr) {
  int n = vec.size();
  vector<int> visited(n, 0);
  queue<pair<int, int>> q;
  q.push(make_pair(curr, 0));
  visited[curr] = 1;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    int temp = p.first;
    int dis = p.second;
    if (temp == dest) return dis;
    q.pop();
    for (int i = 0; i < vec[temp].size(); ++i) {
      if (!visited[vec[temp][i]]) {
        visited[vec[temp][i]] = 1;
        q.push(make_pair(vec[temp][i], dis + 1));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, u, v;
  cin >> n >> u >> v;
  vector<vector<int>> vec(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    vec[a - 1].push_back(b - 1);
    vec[b - 1].push_back(a - 1);
  }
  vector<int> vec1;
  for (int i = 0; i < n; ++i) {
    if (vec[i].size() == 1) {
      vec1.push_back(i);
    }
  }
  int max = INT_MIN;
  for (int i = 0; i < vec1.size(); ++i) {
    int temp = vec1[i];
    int a, b;
    a = dist(vec, temp, u - 1);
    b = dist(vec, temp, v - 1);
    if (a <= b) {
      if (b > max) {
        max = b;
      }
    }
  }
  cout << max - 1 << "\n";
}
