#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, q, cc, dfn, ll[N], rr[N], dep[N], fa[22][N], hd[N], nxt[N << 1],
    to[N << 1], tg[N << 2], s[N << 2];
map<long long, int> mp;
void add(int u, int v) {
  nxt[++cc] = hd[u];
  hd[u] = cc;
  to[cc] = v;
}
void dfs(int x, int p) {
  ll[x] = ++dfn;
  dep[x] = dep[p] + 1;
  fa[0][x] = p;
  for (int i = hd[x]; i; i = nxt[i])
    if (to[i] != p) dfs(to[i], x);
  rr[x] = dfn;
}
void upd(int x, int l, int r, int tl, int tr, int v) {
  if (tl > tr) return;
  if (tl <= l && r <= tr) {
    tg[x] += v;
    if (tg[x])
      s[x] = r - l + 1;
    else if (l == r)
      s[x] = 0;
    else
      s[x] = s[x << 1] + s[x << 1 | 1];
    return;
  }
  int mid = l + r >> 1;
  if (tl <= mid) upd(x << 1, l, mid, tl, tr, v);
  if (tr > mid) upd(x << 1 | 1, mid + 1, r, tl, tr, v);
  if (tg[x])
    s[x] = r - l + 1;
  else
    s[x] = s[x << 1] + s[x << 1 | 1];
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  dfs(1, 0);
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) fa[i][j] = fa[i - 1][fa[i - 1][j]];
  while (q--) {
    int u, v, c;
    scanf("%d%d", &u, &v);
    if (ll[u] > ll[v]) swap(u, v);
    long long tt = u * 200007ll + v;
    if (mp[tt])
      c = 1, mp[tt] = 0;
    else
      c = -1, mp[tt] = 1;
    if (rr[u] >= rr[v]) {
      int t = v;
      for (int j = 20; j >= 0; j--)
        if (dep[fa[j][t]] > dep[u]) t = fa[j][t];
      upd(1, 1, n, ll[t], ll[v] - 1, c);
      upd(1, 1, n, rr[v] + 1, rr[t], c);
    } else
      upd(1, 1, n, 1, ll[u] - 1, c), upd(1, 1, n, rr[u] + 1, ll[v] - 1, c),
          upd(1, 1, n, rr[v] + 1, n, c);
    printf("%d\n", n - s[1]);
  }
  return 0;
}
