#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define N 100005
using namespace std;
struct edge{int v,w;};
vector<edge>edges[N];
int grand[N][25]={0},gw[N][25]={0};
int depth[N],DEPTH,n;
void addedge(int a,int b,int w)
{
edges[a].push_back((edge){b,w});
edges[b].push_back((edge){a,w});
}
void dfs(int x)
{
for(int i=1;i<=DEPTH;i++)
{
grand[x][i]=grand[grand[x][i-1]][i-1];
gw[x][i]=gw[x][i-1]+gw[grand[x][i-1]][i-1];
}
for(int i=0;i<edges[x].size();i++)
{
int to=edges[x][i].v;
if(grand[x][0]==to)continue;
depth[to]=depth[x]+1;
grand[to][0]=x;
gw[to][0]=edges[x][i].w;
dfs(to);
}
}
void init()
{
DEPTH=floor(log(n + 0.0) / log(2.0));
depth[1]=0;
memset(grand,0,sizeof(grand));
memset(gw,0,sizeof(gw));
dfs(1);
}
int lca(int a,int b)
{
if(depth[a]>depth[b])swap(a,b);
int ans=0;
for(int i=DEPTH;i>=0;i--)
if(depth[a]<depth[b]&&depth[grand[b][i]]>=depth[a])
ans+=gw[b][i],b=grand[b][i];
for(int i=DEPTH;i>=0;i--)
if(grand[a][i]!=grand[b][i])
{
ans+=gw[a][i];
ans+=gw[b][i];
a=grand[a][i];
b=grand[b][i];
}
if(a!=b)
{
ans+=gw[a][0];
ans+=gw[b][0];
}
return ans;
}
int main()
{
int a,b;
scanf("%d",&n);
for(int i=0;i<n-1;i++)
{
scanf("%d %d",&a,&b);
addedge(a,b,1);
}
init();
int ans=0;
int m,last=1;
scanf("%d",&m);
while(m--)
{
scanf("%d",&a);
ans+=lca(last,a);
last=a;
}
printf("%d",ans);
return 0;
}