#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
vector<int> g[100100];
int tak, ao;
int dfs(int u, int pa = -1) {
  int ans = 0;
  for (auto v : g[u]) {
    if (v == pa) continue;
    if (v == tak) {
      ans = 1;
    } else {
      ans = max(ans, dfs(v, u) + 1);
    }
  }
  return ans;
}
int main() {
  int N;
  int u, v;
  cin >> N >> tak >> ao;
  tak--;
  ao--;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = dfs(ao);
  cout << ans - 1 << endl;
}
