import sys input = sys.stdin.readline N,Q=map(int,input().split()) E=[[] for i in range(N)] for i in range(N-1): a,b=map(int,input().split()) a-=1 b-=1 E[a].append(b) E[b].append(a) ROOT=0 QUE=[ROOT] DEPTH=[0]*N DEPTH[ROOT]=0 Parent=[-1]*N Parent[ROOT]=N # ROOTの親を定めておく. Child=[[] for i in range(N)] TOP_SORT=[] # トポロジカルソート while QUE: # トポロジカルソートと同時に親を見つける x=QUE.pop() TOP_SORT.append(x) for to in E[x]: if Parent[to]==-1: Parent[to]=x Child[x].append(to) QUE.append(to) DEPTH[to]=DEPTH[x]+1 Children=[1]*N for x in TOP_SORT[::-1]: #(自分を含む)子ノードの数を調べる if x==ROOT: break Children[Parent[x]]+=Children[x] DOUBLING=[[-1]*N for b in range(30)] for i in range(N): if i!=ROOT: DOUBLING[0][i]=Parent[i] for b in range(1,30): for i in range(N): if DOUBLING[b-1][i]!=-1: DOUBLING[b][i]=DOUBLING[b-1][DOUBLING[b-1][i]] # 頂点aの先祖で深さdの頂点を探す def search_depth(a,d): now=a for b in range(30,-1,-1): if (DEPTH[a]-d) & (1<DEPTH[y]: x=search_depth(x,DEPTH[y]) if x==y: return x for b in range(29,-1,-1): if DOUBLING[b][x]!=DOUBLING[b][y]: x=DOUBLING[b][x] y=DOUBLING[b][y] if Parent[x]==Parent[y]: return Parent[x] for tests in range(Q): a,b=map(int,input().split()) a-=1 b-=1 if DEPTH[a]>DEPTH[b]: a,b=b,a LCA=lca(a,b) if LCA==a: dis=DEPTH[b]-DEPTH[a] if dis%2==1: print(0) continue else: x=search_depth(b,DEPTH[b]-dis//2) y=search_depth(b,DEPTH[b]-dis//2+1) print(Children[x]-Children[y]) else: dis1=DEPTH[a]-DEPTH[LCA] dis2=DEPTH[b]-DEPTH[LCA] if (dis1+dis2)%2==1: print(0) continue else: if dis1==dis2: print(N-Children[LCA]+1) elif dis1>dis2: x=search_depth(a,DEPTH[a]-(dis1+dis2)//2) y=search_depth(a,DEPTH[a]-(dis1+dis2)//2+1) print(Children[x]-Children[y]) else: x=search_depth(b,DEPTH[b]-(dis1+dis2)//2) y=search_depth(b,DEPTH[b]-(dis1+dis2)//2+1) print(Children[x]-Children[y])