from collections import deque N, Q = map(int,input().split()) G = [[] for _ in range(N)] for _ in range(N-1): a, b = map(int,input().split()) a -= 1 b -= 1 G[a].append(b) G[b].append(a) for _ in range(Q): s, t = map(int, input().split()) s -= 1 t -= 1 #sを始点にbfs dist_s = [-1]*N dist_s[s] = 0 q = deque([s]) while q: now = q.popleft() for next in G[now]: if dist_s[next]!=-1: continue dist_s[next] = dist_s[now] + 1 q.append(next) #tを始点にbfs dist_t = [-1]*N dist_t[t] = 0 q = deque([t]) while q: now = q.popleft() for next in G[now]: if dist_t[next]!=-1: continue dist_t[next] = dist_t[now] + 1 q.append(next) ans = 0 for i in range(N): if dist_s[i] == dist_t[i]: ans += 1 print(ans)