#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[200005];
int dfn[200005], sz[200005], cnt, f[200005][25], dep[200005];
map<int, map<int, int> > flag;
int c[800005], len[800005];
void dfs(int u, int pre) {
  dfn[u] = ++cnt;
  sz[u] = 1;
  dep[u] = dep[pre] + 1;
  for (int i = 1; i <= 20; i++) f[u][i] = f[f[u][i - 1]][i - 1];
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == pre) continue;
    f[v][0] = u;
    dfs(v, u);
    sz[u] += sz[v];
  }
}
int getpre(int x, int y) {
  for (int i = 20; i >= 0; i--)
    if (dep[f[x][i]] > dep[y]) x = f[x][i];
  return x;
}
void pushup(int x, int l, int r) {
  if (c[x] > 0)
    len[x] = r - l + 1;
  else if (l == r)
    len[x] = 0;
  else
    len[x] = len[x << 1] + len[x << 1 | 1];
}
void update(int x, int l, int r, int L, int R, int k) {
  if (L > R) return;
  if (L <= l && r <= R) {
    c[x] += k;
    pushup(x, l, r);
    return;
  }
  int mid = l + r >> 1;
  if (L <= mid) update(x << 1, l, mid, L, R, k);
  if (R > mid) update(x << 1 | 1, mid + 1, r, L, R, k);
  pushup(x, l, r);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v), g[v].push_back(u);
  }
  dfs(1, 0);
  while (m--) {
    int u, v, tmp;
    scanf("%d%d", &u, &v);
    if (dfn[u] > dfn[v]) swap(u, v);
    if (dfn[v] < dfn[u] + sz[u] && dfn[v] >= dfn[u]) {
      int s = getpre(v, u);
      flag[u][v] = 1 - flag[u][v];
      tmp = -1 + 2 * flag[u][v];
      update(1, 1, n, dfn[s], dfn[v] - 1, tmp);
      update(1, 1, n, dfn[v] + sz[v], dfn[s] + sz[s] - 1, tmp);
    } else {
      flag[u][v] = 1 - flag[u][v];
      tmp = -1 + 2 * flag[u][v];
      update(1, 1, n, 1, dfn[u] - 1, tmp);
      update(1, 1, n, dfn[u] + sz[u], dfn[v] - 1, tmp);
      update(1, 1, n, dfn[v] + sz[v], n, tmp);
    }
    printf("%d\n", n - len[1]);
  }
  return 0;
}
