import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 class LCA: def __init__(self, parent, depth): n = len(parent) self._depth = depth log = max(self._depth).bit_length() self._table = [parent]+[[-1]*n for _ in range(log)] row0 = self._table[0] for lv in range(log): row1 = self._table[lv+1] for u in range(n): if row0[u] == -1: continue row1[u] = row0[row0[u]] row0 = row1 def anc(self, u, v): diff = self._depth[u]-self._depth[v] if diff < 0: u, v = v, u diff = abs(diff) u = self.up(u, diff) if u == v: return u,-1,-1 for lv in range(self._depth[u].bit_length()-1, -1, -1): anclv = self._table[lv] if anclv[u] != anclv[v]: u, v = anclv[u], anclv[v] return self._table[0][u],u,v def up(self, u, dist): lv = 0 while dist and u != -1: if dist & 1: u = self._table[lv][u] lv, dist = lv+1, dist >> 1 return u n,q=LI() to=[[] for _ in range(n)] for _ in range(n-1): u,v=LI1() to[u].append(v) to[v].append(u) def dfs(root=0): uu, stack = [], [root] while stack: u = stack.pop() uu.append(u) for v in to[u]: if v == parent[u]: continue parent[v] = u depth[v] = depth[u]+1 stack.append(v) return uu parent, depth = [-1]*n, [0]*n uu = dfs() dp=[1]*n for u in uu[:0:-1]: p=parent[u] dp[p]+=dp[u] lca=LCA(parent,depth) for _ in range(q): u,v=LI1() a,pu,pv=lca.anc(u,v) d=depth[u]+depth[v]-depth[a]*2 if d&1: print(0) elif depth[u]==depth[v]: print(n-dp[pu]-dp[pv]) else: if depth[u]>depth[v]: u,v=v,u pu,pv=pv,pu pv=lca.up(v,d//2-1) m=parent[pv] print(dp[m]-dp[pv])