TMD树剖过不掉。
#pragma GCC optimize("O2")
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
#define rep(i,j,k) for(i=j;i<=k;++i)
#define per(i,j,k) for(i=j;i>=k;--i)
#define G getchar()
#define LL long long
#define pll pair<int,int>
#define mkp make_pair
#define X first
#define Y second
const int N=100005;
int n,m;LL f[N],ans;
int he[N],ne[N<<1],to[N<<1],tot;
int sz[N],dad[N],son[N],cnt,pre[N],dep[N];
void read(int &x){
char ch=getchar();
while(ch<48||ch>57)ch=G;
for(x=0;ch>=48&&ch<=57;ch=G)x=x*10+ch-48;
}
void add(int x,int y){
to[++tot]=y;ne[tot]=he[x];he[x]=tot;
}
void DFS1(int x,int e){
int y,i;sz[x]=1;
for(i=he[x];i;i=ne[i])if(i!=e){
pre[y=to[i]]=x;
DFS1(y,i^1);
if(sz[son[x]]<sz[y])son[x]=y;
sz[x]+=sz[y];
}
}
void DFS2(int x){
int i,y;dep[x]=dep[pre[x]]+1;
dad[x]=son[pre[x]]==x?dad[pre[x]]:x;
if(son[x])DFS2(son[x]);
for(i=he[x];i;i=ne[i])if((y=to[i])!=pre[x])
DFS2(y);
}
int lca(int x,int y){
int fx=dad[x],fy=dad[y];
while(fx!=fy)
if(dep[fx]>dep[fy])fx=dad[x=pre[fx]];
else fy=dad[y=pre[fy]];
return dep[x]<dep[y]?x:y;
}
void dp(int x){
int i,y;
for(i=he[x];i;i=ne[i])if((y=to[i])!=pre[x]){
dp(y);f[x]+=f[y];
}
if(f[x]==1)++ans;
else if(!f[x]&&x>1)ans+=m;
}
int main(){
int i,x,y;
read(n);read(m);tot=1;
rep(i,2,n){
read(x);read(y);
add(x,y);add(y,x);
}
DFS1(1,0);DFS2(1);
rep(i,1,m){
read(x);read(y);
++f[x];++f[y];f[lca(x,y)]-=2;
}
dp(1);printf("%lld\n",ans);
return 0;
}