#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = 1000000007;
vector<vector<int> > edge(100010, vector<int>(0));
vector<int> diff(100010);
int c = 0;
void ddfs(int v, int p, int d) {
  diff[v] = d;
  for (int i = 0; i < edge[v].size(); i++) {
    if (edge[v][i] != p) {
      ddfs(edge[v][i], v, d + 1);
    }
  }
}
void dfs(int v, int p, int d) {
  if (d <= diff[v]) c = max(c, d);
  if (d >= diff[v]) return;
  for (int i = 0; i < edge[v].size(); i++) {
    if (edge[v][i] != p) {
      dfs(edge[v][i], v, d + 1);
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  ddfs(v, -1, 0);
  dfs(u, -1, 0);
  cout << c;
}
