/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/

/+---test
5 4 1
1 2
2 3
3 4
3 5
---+/
/+---test
5 4 5
1 2
1 3
1 4
1 5
---+/
/+---test
2 1 2
1 2
---+/
/+---test
9 6 1
1 2
2 3
3 4
4 5
5 6
4 7
7 8
8 9
---+/

void main(string[] args) {
  long N, u, v;
  readf(" %d %d %d ", &N, &u, &v);
  --u; --v;

  auto E = new long[][](N);
  foreach (i; 0..N-1) {
    long a, b;
    readf(" %d %d ", &a, &b);
    --a; --b;
    E[a] ~= b;
    E[b] ~= a;
  }

  auto level    = new long[](N);
  auto parent   = new long[](N);
  auto children = new long[][](N);
  auto dist     = new long[](N);

  long setlevel(size_t x, long l, long p = -1) {
    if (p != -1) {
      parent[x] = p;
    }
    level[x] = l;

    long maxdist;
    foreach (e; E[x]) {
      if (e != p) {
        maxdist.amax(setlevel(e, l+1, x) + 1);
        children[x] ~= e;
      }
    }
    dist[x] = maxdist;
    return maxdist;
  }

  parent[] = -1;
  level[]  = -1;
  setlevel(u, 0);

  long ans = level[v] <= 2? 0: (level[v]-1)/2;

  u = v;
  foreach (i; 0..ans+1) u = parent[u];

  if (level[v]%2 == 0) {
    u = parent[u];
    ++ans;
  }

  parent[] = -1;
  level[]  = -1;
  setlevel(u, 0);

  long aoki_branch = v;
  while (parent[aoki_branch] != u) {
    aoki_branch = parent[aoki_branch];
  }

  long taka_branch = -1;
  foreach (c; children[u]) {
    if (c == aoki_branch) continue;
    if (taka_branch == -1 || dist[taka_branch] < dist[c]) {
      taka_branch = c;
    }
  }
  if (taka_branch != -1) {
    ans += dist[taka_branch]+1;
  }
  ans.writeln;
}
