// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define ri register int 

namespace io {

	const int SIZE = (1 << 21) + 1;

	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;

	// getchar

	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)

	// print the remaining part

	inline void flush () {

		fwrite (obuf, 1, oS - obuf, stdout);

		oS = obuf;

	}

	// putchar

	inline void putc (char x) {

		*oS ++ = x;

		if (oS == oT) flush ();

	}

	// input a signed integer

	template <class I>

	inline void gi (I &x) {

		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;

		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;

	}

	// print a signed integer

	template <class I>

	inline void print (I x) {

		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;

		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;

		while (qr) putc (qu[qr --]);

	}

	// no need to call flush at the end manually!

	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;

} 

using io :: gi;

using io :: putc;

using io :: print;

const int N=2e3+5;

#define bit bitset<N>

struct node{

	int tot,head[N],nxt[N<<1],adj[N<<1],top[N],sz[N],f[N],dep[N],son[N];

	bit p[N],q[N];

	inline void addedge(ri x,ri y){

		nxt[++tot]=head[x];

		adj[head[x]=tot]=y;

	}

	inline void dfs(ri x){

		sz[x]=1;

		p[x][x]=q[x][x]=1;

		for(ri y,i=head[x];i;i=nxt[i])

			if((y=adj[i])!=f[x])

				p[y]=p[x],

				f[y]=x,

				dep[y]=dep[x]+1,

				dfs(y),

				q[x]|=q[y],

				sz[x]+=sz[y],

				son[x]=sz[y]>sz[son[x]]?y:son[x];

	}

	inline void dfs2(ri x,ri tp){

		top[x]=tp;

		if(son[x])

			dfs2(son[x],tp);

		for(ri y,i=head[x];i;i=nxt[i])

			if((y=adj[i])!=f[x]&&y!=son[x])

				dfs2(y,y);

	}

	inline int lca(ri x,ri y){

		while(top[x]^top[y])

			if(dep[top[x]]>dep[top[y]])

				x=f[top[x]];

			else

				y=f[top[y]];

		return dep[x]<dep[y]?x:y; 

	}

	inline int sec(ri x,ri y){ // lca(x,y) = x

		while(top[x]^top[y]){

			if(f[top[y]]==x) return top[y];

			y=f[top[y]];

		}

		return son[x];

	}

	inline bit S(ri a,ri b){

		ri x=lca(a,b);

		bit ans=p[a]^p[b];

		ans[x]=1;

		if(x!=b)

			ans|=q[b];

		else

			ans|=~q[sec(b,a)];

		if(x!=a)

			ans|=q[a];

		else

			ans|=~q[sec(a,b)]; 

		return ans;

	}

}t;

#define pii pair<int,int>

#define fi first

#define se second

#define mp make_pair 

pii qu[N*N];

bit nG[N];

int main(){

	ri n,m,i,x,y,l,r;

	l=1;r=0;

	gi(n);gi(m);

	for(i=1;i^n;++i)

		gi(x),gi(y),

		t.addedge(x,y),

		t.addedge(y,x);

	t.dfs(1);

	t.dfs2(1,1);

	while(m--)

		gi(x),gi(y),

		nG[x][y]=nG[y][x]=1,

		qu[++r]=mp(x,y);

	while(l<=r){

		x=qu[l].fi;

		y=qu[l].se;

		++l;

		bit now=(nG[x]^nG[y])&t.S(x,y);

		now[x]=now[y]=0;

		for(i=now._Find_first();i!=now.size();i=now._Find_next(i))

			if(!nG[x][i])

				nG[x][i]=nG[i][x]=1,

				qu[++r]=mp(x,i);

			else

				nG[y][i]=nG[i][y]=1,

				qu[++r]=mp(y,i);

	}

	printf("%d\n",r);

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define ri register int 

namespace io {

	const int SIZE = (1 << 21) + 1;

	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;

	// getchar

	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)

	// print the remaining part

	inline void flush () {

		fwrite (obuf, 1, oS - obuf, stdout);

		oS = obuf;

	}

	// putchar

	inline void putc (char x) {

		*oS ++ = x;

		if (oS == oT) flush ();

	}

	// input a signed integer

	template <class I>

	inline void gi (I &x) {

		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;

		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;

	}

	// print a signed integer

	template <class I>

	inline void print (I x) {

		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;

		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;

		while (qr) putc (qu[qr --]);

	}

	// no need to call flush at the end manually!

	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;

} 

using io :: gi;

using io :: putc;

using io :: print;

const int N=2005;

int tot,head[N],nxt[N<<1],adj[N<<1],mark[N][N],fa[N][N];

inline void addedge(ri x,ri y){

	nxt[++tot]=head[x];

	adj[head[x]=tot]=y;

}

inline void predfs(ri u,ri x){

	for(ri y,i=head[x];i;i=nxt[i])

		if((y=adj[i])!=fa[u][x])

			fa[u][y]=x,

			predfs(u,y);

}

#define pii pair<int,int>

#define mp make_pair

#define fi first

#define se second

pii q[N*N];

int r,ans;

inline void dfs(ri u,ri v,ri x){

	mark[u][x]=v;

	for(ri y,i=head[x];i;i=nxt[i])

		if((y=adj[i])!=fa[u][x]){

			if(!mark[u][y])

				dfs(u,v,y);

			else // mark[u][y] == y

				q[++r]=mp(v,mark[u][y]);

		}

}

inline void calc(ri x,ri lst,ri u){

	if(mark[u][x]==x)

		++ans,u=x;

	for(ri y,i=head[x];i;i=nxt[i])

		if((y=adj[i])!=lst)

			calc(y,x,u);

}

int main(){

	ri n,m,i,x,y,l;

	gi(n);gi(m);

	for(i=1;i^n;++i)

		gi(x),gi(y),

		addedge(x,y),

		addedge(y,x);

	for(i=1;i<=n;++i)

		predfs(i,i);

	l=1;r=0;

	while(m--) gi(x),gi(y),q[++r]=mp(x,y);

	while(l<=r){

		x=q[l].fi;

		y=q[l].se;

		++l;

		while(mark[x][y]) x=mark[x][y];

		while(mark[y][x]) y=mark[y][x];

		if(x==y) continue;

		dfs(x,y,y);

		dfs(y,x,x);

	}

	for(x=1;x<=n;++x)

		for(i=head[x];i;i=nxt[i])

			calc(adj[i],x,x);

	ans>>=1;

	printf("%d\n",ans);

    return 0;

}

// Fastest known solution for this problem: