import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class prog {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		kspecialists solver = new kspecialists();
		solver.solve(1, in, out);
		out.close();
	}
}

class kspecialists {
    int[] specCount;
    int[] serverCount;
    int[] specNode;
    boolean[] isServer;
    ArrayList<Integer>[] A;
    int[] T;
    int[] D;

    int smin, vmin;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int K = in.nextInt();
        specCount = new int[N];
        serverCount = new int[N];
        specNode = new int[N];
        isServer = new boolean[N];
        for (int i = 0; i < K; i++) {
            int a = in.nextInt();
            a--;
            specCount[a]++;
            specNode[i] = a;
        }
        for (int i = 0; i < K; i++) {
            int b = in.nextInt();
            b--;
            serverCount[b]++;
            isServer[b] = true;
        }

        A = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            A[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < N - 1; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            A[a].add(b);
            A[b].add(a);
        }

        D = new int[K];
        T = new int[N];
        dfs(0, -1);

        int ans = 0;
        boolean ok = true;
        while (ok) {
            ok = false;
            for (int i = 0; i < K; i++) {
                int s = specNode[i];
                if (specCount[s] > serverCount[s]) {
                    int t = T[s];
                    specCount[s]--;
                    specNode[i] = t;
                    D[i]++;
                    ok = true;
                }
            }
        }

        boolean[] used = new boolean[K];
        for (int it = 0; it < K; it++) {
            int pmax = -1;
            for (int i = 0; i < K; i++) {
                if (!used[i]) {
                    if (pmax == -1 || D[i] > D[pmax]) {
                        pmax = i;
                    }
                }
            }
            used[pmax] = true;

            smin = -1;
            vmin = Integer.MAX_VALUE;
            go(specNode[pmax], 0);
            isServer[smin] = false;
            ans = Math.max(ans, vmin + D[pmax]);
        }

        out.println(ans);
    }

    private void go(int node, int dist) {
        if (dist > 0 && specCount[node] >= serverCount[node]) {
            return;
        }
        if (isServer[node]) {
            if (dist < vmin) {
                vmin = dist;
                smin = node;
            }
            return;
        }
        for (int x : A[node]) {
            if (x != T[node]) {
                go(x, dist + 1);
            }
        }
    }

    private void dfs(int node, int prev) {
        T[node] = prev;
        for (int x : A[node]) {
            if (x != prev) {
                dfs(x, node);
                specCount[node] += specCount[x];
                serverCount[node] += serverCount[x];
            }
        }
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}