#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const long long INF = 2e9 + 10;
struct edge {
  int to, next;
} G[maxn << 1];
int tot, head[maxn];
void addEdge(int u, int v) {
  G[tot] = {v, head[u]};
  head[u] = tot++;
};
int n, s, t, vis[2][maxn];
void dfs(int u, int fa, int x) {
  for (int i = head[u]; i != -1; i = G[i].next)
    if (G[i].to != fa) vis[x][G[i].to] = vis[x][u] + 1, dfs(G[i].to, u, x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> s >> t;
  int u, v;
  for (int i = 1; i <= n; i++) head[i] = -1;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    addEdge(u, v);
    addEdge(v, u);
  }
  dfs(s, -1, 0);
  dfs(t, -1, 1);
  int ans = 0, mi = INF;
  for (int i = 1; i <= n; i++) {
    if (vis[0][i] < vis[1][i])
      ans = max(ans, vis[1][i] - 1);
    else if (vis[0][i] == vis[1][i])
      mi = min(mi, vis[0][i]);
  }
  cout << max(ans, (mi == INF ? 0 : mi)) << "\n";
}
