#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
struct edge{
int to,nxt;
}d[N]; int head[N],cnt=1;
void add(int u,int v){ d[++cnt]=(edge){v,head[u]},head[u]=cnt; }
int n,m,son[N],siz[N],deep[N],fa[N][20],an[N];
int top[N];
void dfs(int u,int father,int depth){
siz[u]=1,deep[u]=depth,fa[u][0]=father;
int maxson=-1;
for(int i=head[u];i;i=d[i].nxt ){
int v=d[i].to;
if( v==father ) continue;
dfs(v,u,depth+1);
siz[u]+=siz[v];
if( maxson<siz[v] ) maxson=siz[v],son[u]=v;
}
}
void dfs2(int x,int t){
top[x]=t;
if(son[x]==0) return ;
dfs2(son[x],t);
for(int i=head[x];i;i=d[i].nxt){
int v=d[i].to;
if(v!=son[x]&&v!=fa[x][0]) dfs2(v,v);
}
}
int query(int a,int b){
while(top[a]!=top[b]){
if(deep[top[a]]>deep[top[b]]){
a=fa[top[a]][0];
}else{
b=fa[top[b]][0];
}
}
return deep[a]>deep[b]?b:a;
}
int cha[N];int ans=0;
void dfs3(int x,int father){
for(int i=head[x];i;i=d[i].nxt){
int v=d[i].to;
if(v==father) continue;
dfs3(v,x);
cha[x]+=cha[v];
}
if(x==1) return ;
if(cha[x]==0) ans+=m;
else if(cha[x]==1) ans+=1;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<n;i++){
int a,b;scanf("%d%d",&a,&b);
add(a,b);add(b,a);
}
dfs(1,0,1);
dfs2(1,1);
for(int i=1;i<=m;i++){
int a,b;scanf("%d%d",&a,&b);
int lcapos=query(a,b);
cha[lcapos]-=2;cha[a]+=1;cha[b]+=1;
}
dfs3(1,0);
cout<<ans<<endl;
}