#include <bits/stdc++.h>
using namespace std;
int N, u, v;
vector<int> G[100005];
void dfs(int x, int px, int d, vector<int>& dist) {
  if (dist[x] != -1) return;
  dist[x] = d;
  for (int i = (0); i < (int)(G[x].size()); i++) {
    if (G[x][i] == px) continue;
    dfs(G[x][i], x, d + 1, dist);
  }
}
void dfs2(int x, int px, int d, vector<int>& dist, vector<int>& dist2) {
  if (dist[x] <= d) return;
  if (dist2[x] != -1) return;
  dist2[x] = d;
  for (int i = (0); i < (int)(G[x].size()); i++) {
    if (G[x][i] == px) continue;
    dfs2(G[x][i], x, d + 1, dist, dist2);
  }
}
int main() {
  cin >> N >> u >> v;
  u--;
  v--;
  for (int i = (0); i < (int)(N - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> taka(N, -1), ao(N, -1);
  dfs(v, -1, 0, ao);
  dfs2(u, -1, 0, ao, taka);
  int mx = -1;
  vector<int> goals;
  for (int i = (0); i < (int)(N); i++) {
    if (taka[i] == -1) continue;
    if (ao[i] > taka[i]) {
      if (mx < ao[i]) {
        mx = ao[i];
        goals.clear();
        goals.push_back(i);
      } else if (mx == ao[i]) {
        goals.push_back(i);
      }
    }
  }
  int mxret = 0;
  for (int rr = (0); rr < (int)(goals.size()); rr++) {
    int goal = goals[rr];
    vector<int> ru, rv;
    int nx = goal;
    while (taka[nx] != 0) {
      ru.push_back(nx);
      int y = -1;
      for (int i = (0); i < (int)(G[nx].size()); i++) {
        if (taka[nx] - 1 == taka[G[nx][i]]) {
          y = G[nx][i];
        }
      }
      nx = y;
    }
    nx = goal;
    while (ao[nx] != 0) {
      rv.push_back(nx);
      int y = -1;
      for (int i = (0); i < (int)(G[nx].size()); i++) {
        if (ao[nx] - 1 == ao[G[nx][i]]) {
          y = G[nx][i];
        }
      }
      nx = y;
    }
    reverse((ru).begin(), (ru).end());
    reverse((rv).begin(), (rv).end());
    int ret = 0;
    int i = 0, j = 0;
    while (true) {
      if (i < ru.size()) {
        u = ru[i];
        i++;
      } else {
        int x = -1;
        for (int ii = (0); ii < (int)(G[u].size()); ii++) {
          x = G[u][ii];
        }
        u = x;
      }
      if (u == v) break;
      if (j < rv.size()) {
        v = rv[j];
        j++;
      } else {
        int x = -1;
        for (int ii = (0); ii < (int)(G[u].size()); ii++) {
          x = G[u][ii];
        }
        v = x;
      }
      ret++;
      if (u == v) break;
    }
    mxret = max(mxret, ret);
  }
  cout << mxret << endl;
  return 0;
}
