#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;
template <typename T>
T gcd(T a, T b) {
  if (a < b) return gcd(b, a);
  T r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
template <typename T>
T lcm(const T a, const T b) {
  return a / gcd(a, b) * b;
}
chrono::high_resolution_clock::time_point step_time[10];
int step_time_i = 0;
void measure_time() {
  step_time[step_time_i++] = chrono::high_resolution_clock::now();
}
double calc_microsecond(const chrono::high_resolution_clock::time_point &a,
                        const chrono::high_resolution_clock::time_point &b) {
  return chrono::duration_cast<chrono::microseconds>(b - a).count() / 1000.0;
}
void print_time() {
  if (step_time_i < 2) return;
  fprintf(stderr, "Time: ");
  if (step_time_i > 2)
    fprintf(stderr, "%.3f ",
            calc_microsecond(step_time[0], step_time[step_time_i - 1]));
  for (int i = 0; i < (int)(step_time_i - 1); ++i)
    fprintf(stderr, "%.3f ", calc_microsecond(step_time[i], step_time[i + 1]));
  fprintf(stderr, "\n");
}
char buf[1000 * 1000];
int bufi = 0;
template <typename T>
void readi(T &n) {
  bool negative = false;
  int c;
  n = 0;
  c = buf[bufi++];
  if (c == '-') negative = true, c = buf[bufi++];
  for (; '0' <= c && c <= '9'; c = buf[bufi++]) n = 10 * n + c - '0';
  if (negative) n = -n;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
int main() {
  cout << fixed << setprecision(15);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, u, v;
  vector<int> adj[100100];
  cin >> n >> u >> v;
  u -= 1;
  v -= 1;
  for (int i = 0; i < (int)(n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int d[100100];
  d[u] = 0;
  bool visited[100100];
  memset(visited, 0, sizeof visited);
  stack<int> dfs;
  dfs.push(u);
  while (!dfs.empty()) {
    int x = dfs.top();
    visited[x] = true;
    dfs.pop();
    for (int i = 0; i < (int)(adj[x].size()); ++i)
      if (!visited[adj[x][i]]) {
        dfs.push(adj[x][i]);
        d[adj[x][i]] = d[x] + 1;
      }
  }
  int dv[100100];
  dv[v] = 0;
  memset(visited, 0, sizeof visited);
  dfs.push(v);
  while (!dfs.empty()) {
    int x = dfs.top();
    visited[x] = true;
    dfs.pop();
    for (int i = 0; i < (int)(adj[x].size()); ++i)
      if (!visited[adj[x][i]]) {
        dfs.push(adj[x][i]);
        dv[adj[x][i]] = dv[x] + 1;
      }
  }
  int ans = 0;
  memset(visited, 0, sizeof visited);
  dfs.push(u);
  while (!dfs.empty()) {
    int x = dfs.top();
    visited[x] = true;
    dfs.pop();
    for (int i = 0; i < (int)(adj[x].size()); ++i) {
      int y = adj[x][i];
      if (!visited[y] && d[y] <= dv[y]) {
        int t = -1 + d[y] + dv[y] - d[y];
        if ((d[x] - dv[x]) % 2 == 1 || d[y] == dv[y]) t += 1;
        chmax(ans, t);
        if (d[y] < dv[y]) dfs.push(y);
      }
    }
  }
  cout << (ans) << '\n';
  return 0;
}
