#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
vector<vector<int>> g(100001);
vector<int> d_ta(100001, -1), d_ao(100001, -1);
void dfs1(int now, int depth) {
  d_ta[now] = depth;
  for (int i = 0; i < g[now].size(); ++i) {
    int next = g[now][i];
    if (d_ta[next] == -1) dfs1(next, depth + 1);
  }
}
void dfs2(int now, int depth) {
  d_ao[now] = depth;
  for (int i = 0; i < g[now].size(); ++i) {
    int next = g[now][i];
    if (d_ao[next] == -1) dfs2(next, depth + 1);
  }
}
int main() {
  int n, ta, ao;
  cin >> n >> ta >> ao;
  ta--;
  ao--;
  int a, b;
  for (int i = 0; i < n - 1; ++i) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(ta, 0);
  dfs2(ao, 0);
  int max = -1, max_node;
  for (int i = 0; i < n; ++i) {
    if (d_ta[i] < d_ao[i] && d_ao[i] > max) {
      max_node = i;
      max = d_ta[i];
    }
  }
  int dis = d_ta[ao];
  cout << d_ao[max_node] - 1 << "\n";
}
