import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class dwarfs_nn_slow {

    static List<Integer>[] edges;

    static void solve() throws IOException {
        int n = nextInt();
        edges = new List[n];
        for (int i = 0; i < n; i++) {
            edges[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i + 1 < n; i++) {
            int v = nextInt() - 1;
            int u = nextInt() - 1;
            edges[v].add(u);
            edges[u].add(v);
        }
        int v1 = nextInt() - 1;
        int v2 = nextInt() - 1;
        int ans = 1;
        for (int i = 0; i < n; i++) {
            for (int j : edges[i]) {
                if (j > i) {
                    ans = Math.max(ans, getAnswer(v1, v2, i, j));
                }
            }
        }
        out.println(ans);
    }

    static int getAnswer(int v1, int v2, int b1, int b2) {
        int[] d1 = bfs(v1, b1, b2);
        if (d1[v2] != Integer.MAX_VALUE) return 0;
        int[] d2 = bfs(v2, b1, b2);
        return Math.min(getMaximal(d1), getMaximal(d2)) + 1;
    }

    static int getMaximal(int[] d) {
        int ret = 0;
        for (int i : d) {
            if (i == Integer.MAX_VALUE) {
                continue;
            }
            ret = Math.max(ret, i);
        }
        return ret;
    }

    static int[] bfs(int start, int b1, int b2) {
        Queue<Integer> q = new ArrayDeque<Integer>();
        int n = edges.length;
        int[] d = new int[n];
        Arrays.fill(d, Integer.MAX_VALUE);
        d[start] = 0;
        q.add(start);
        while (!q.isEmpty()) {
            int v = q.poll();
            for (int i : edges[v]) {
                if (v == b1 && i == b2 || v == b2 && i == b1) {
                    continue;
                }
                if (d[i] == Integer.MAX_VALUE) {
                    d[i] = d[v] + 1;
                    q.add(i);
                }
            }
        }
        return d;
    }

    static StringTokenizer tokenizer;
    static BufferedReader reader;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new FileReader("dwarfs.in"));
        out = new PrintWriter("dwarfs.out");
        solve();
        out.close();
        reader.close();
    }

    static String next() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = reader.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

}
