#include <iostream>
#include <cstring> 
#include <queue>
#define pb push_back
#define ll long long 
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dow(i, j, k) for(int i = j; i >= k; i--) 
using namespace std;//命名空间
const int N = 1e6 + 5;
int n, m, res, fa[N][25], dep[N], poi[N];
vector<int> g[N];
inline void dfs1(int u, int fat)
{
	dep[u] = dep[fat] + 1;
	fa[u][0] = fat;
	for(int i = 1; (1 << i) <= dep[u]; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
	for(int i = 0; i < g[u].size(); i++){
		int v = g[u][i];
		if(v == fat) continue;
		dfs1(v, u);
	}
}
inline void dfs2(int u, int fat)
{
	for(auto v : g[u]){
		if(v == fat) continue;
		dfs2(v, u);
		poi[u] += poi[v];
	}
	res = max(res, poi[u]);
}
inline int lca(int u, int v)
{
	if(dep[u] < dep[v]) swap(u, v);
	dow(i, 30, 0)
		if(dep[u] - (1 << i) >= dep[v]) u = fa[u][i];
	if(u == v) return u;
	dow(i, 30, 0)
		if(fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
	return fa[u][0];
}
int main()//主函数
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	rep(i, 1, n - 1){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs1(1, 0);
	rep(i, 1, m){
		int x, y;
		cin >> x >> y;
		int z = lca(x, y);
		poi[x]++, poi[y]++;
		poi[z]--, poi[fa[z][0]]--;
	}
	dfs2(1, -1);
	cout << res;
	return 0;//华丽结束
}