#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int height[maxn];
vector<int> g[maxn];
bool vis[maxn];
int ans;
void dfs(int x, int d) {
  vis[x] = true;
  for (int y : g[x]) {
    if (!vis[y]) {
      dfs(y, d + 1);
      height[x] = max(height[x], height[y]);
    }
  }
  height[x]++;
  int fw;
  if (d % 2 == 1) {
    fw = d - 1;
  } else {
    fw = d - 2;
  }
  ans = max(ans, fw + height[x] - 1);
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(v, 0);
  cout << ans << endl;
}
