#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, u, v, ans, vis[maxn], d[maxn];
vector<int> g[maxn];
void dfs(int x, int depth) {
  ans = max(ans, depth);
  vis[x] = 1;
  for (unsigned int i = 0; i < g[x].size(); i++) {
    if (!vis[g[x][i]]) dfs(g[x][i], depth + 1);
  }
}
void bfs(int v) {
  queue<int> Q;
  Q.push(v);
  d[v] = 0;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    ans = max(ans, d[x]);
    vis[x] = 1;
    for (unsigned int i = 0; i < g[x].size(); i++) {
      int y = g[x][i];
      if (!vis[y]) Q.push(y), d[y] = d[x] + 1;
    }
  }
}
int main() {
  int a, b;
  cin >> n >> u >> v;
  for (int i = (1); i <= (n); ++i) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(v, 0);
  cout << ans - 1 << endl;
  return 0;
}
