#include <bits/stdc++.h>
using namespace std;
using ll = long long;
queue<int> q;
vector<bool> visit;
typedef struct {
  vector<int> edge;
  int dis_u;
  int dis_v;
} node_t;
vector<node_t> node;
void bfs_u(vector<bool>& visit) {
  int x = q.front();
  q.pop();
  visit[x] = true;
  for (auto to : node[x].edge) {
    if (visit[to]) continue;
    node[to].dis_u = node[x].dis_u + 1;
    q.push(to);
  }
  if (!q.empty()) bfs_u(visit);
}
void bfs_v(vector<bool>& visit) {
  int x = q.front();
  q.pop();
  visit[x] = true;
  for (auto to : node[x].edge) {
    if (visit[to]) continue;
    node[to].dis_v = node[x].dis_v + 1;
    q.push(to);
  }
  if (!q.empty()) bfs_v(visit);
}
bool cmp(const node_t& a, const node_t& b) { return b.dis_v < a.dis_v; }
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  node = vector<node_t>(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    node[a - 1].edge.push_back(b - 1);
    node[b - 1].edge.push_back(a - 1);
  }
  visit = vector<bool>(N);
  q.push(u - 1);
  bfs_u(visit);
  visit = vector<bool>(N);
  q.push(v - 1);
  bfs_v(visit);
  for (int i = 0; i < N; i++) {
    if (node[i].dis_u <= node[i].dis_v) {
      cout << node[i].dis_v - 1 << endl;
      break;
    }
  }
}
