import sys input = sys.stdin.readline sys.setrecursionlimit(500000) n,q=map(int,input().split()) adj=[[] for _ in range(n)] S=[] for _ in range(n-1): a,b=map(int,input().split()) adj[a-1].append(b-1) adj[b-1].append(a-1) S.append((a,b)) depth = [0]*n seen = [0]*n size=[0]*n def dfs(v, e): depth[v] = e seen[v]=1 tot=1 for w in adj[v]: if seen[w]==0: tot+=dfs(w, e+1) size[v]=tot return tot dfs(0, 0) N=n INF = 10 ** 16 depth = [INF] * N dfs_seq = [INF] * N # 0を根にして深さdepthとDFS順序dfs_seqを求める todo = [(0, 0)] count = 0 while todo: d, pos = todo.pop() if dfs_seq[pos] < INF: continue dfs_seq[pos] = count count += 1 depth[pos] = d for next_ in adj[pos]: todo.append((d + 1, next_)) # 2 ** k 個上の頂点を前計算する(k < log2 N) import math K = int(math.log2(N)) + 1 up2 = [[INF] * N for _ in range(K)] for a, b in S: if depth[a-1] < depth[b-1]: up2[0][b-1] = a-1 else: up2[0][a-1] = b-1 for k in range(1, K): for p in range(N): if up2[k-1][p] < INF: up2[k][p] = up2[k-1][up2[k-1][p]] else: up2[k][p] = INF # p個上の頂点をダブリングで求める(p <= depth[n]) def up(n, p): k = 0 while n > 0: if n % 2: p = up2[k][p] if p == INF: break n //= 2 k += 1 return p # 最小共通祖先LCAを求める def lca(p, q): # 深い方のdepthを、浅い方に揃える if depth[p] > depth[q]: p, q = q, p d = depth[p] q = up(depth[q] - d, q) # depthをそろえた頂点が同じであれば、それが答え if p == q: return p # さもなければ、前計算した2**k個上の頂点を順に見比べて、答えを探索する k = K - 1 while k >= 0: p1, q1 = up2[k][p], up2[k][q] if p1 != q1: p, q = p1, q1 else: ans = p1 k -= 1 return ans for _ in range(q): s,t=map(int,input().split()) s-=1 t-=1 x=lca(s,t) d=depth[s]+depth[t]-2*depth[x] if d%2==1: print(0) continue if x==s: u1=up(d//2,t) u2=up(d//2-1,t) print(size[u1]-size[u2]) elif x==t: u1=up(d//2,s) u2=up(d//2-1,s) print(size[u1]-size[u2]) elif depth[s]-depth[x]==d//2: print(n-size[x]+1) else: if depth[s]>depth[t]: u1=up(d//2,s) u2=up(d//2-1,s) print(size[u1]-size[u2]) else: u1=up(d//2,t) u2=up(d//2-1,t) print(size[u1]-size[u2])