#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
vector<int> G[maxn];
map<int, int> mp[maxn];
int sum[maxn * 4], Set[maxn * 4], dep[maxn];
int l[maxn], r[maxn], f[maxn][20], cnt = 0;
void dfs(int u, int fa, int deep) {
  f[u][0] = fa;
  dep[u] = deep;
  l[u] = ++cnt;
  for (int i = 0; i < G[u].size(); i++)
    if (G[u][i] != fa) dfs(G[u][i], u, deep + 1);
  r[u] = cnt;
}
void pushup(int o, int ls, int rs, int l, int r) {
  if (Set[o])
    sum[o] = r - l + 1;
  else if (l == r)
    sum[o] = 0;
  else
    sum[o] = sum[ls] + sum[rs];
}
void up(int o, int l, int r, int ql, int qr, int v) {
  if (l > r) return;
  int m = (l + r) / 2, ls = o * 2, rs = o * 2 + 1;
  if (l >= ql && r <= qr) {
    Set[o] += v;
    pushup(o, ls, rs, l, r);
    return;
  }
  if (ql <= m) up(ls, l, m, ql, qr, v);
  if (qr > m) up(rs, m + 1, r, ql, qr, v);
  pushup(o, ls, rs, l, r);
}
int main() {
  int n, q, x, y, u, v;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0, 1);
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
  while (q--) {
    scanf("%d%d", &x, &y);
    if (l[x] > l[y]) swap(x, y);
    if (!mp[x][y])
      mp[x][y] = 1, v = 1;
    else
      mp[x][y] = 0, v = -1;
    if (r[x] >= r[y]) {
      int Y = y;
      for (int j = 19; j >= 0; j--)
        if (dep[f[Y][j]] > dep[x]) Y = f[Y][j];
      up(1, 1, n, l[Y], l[y] - 1, v), up(1, 1, n, r[y] + 1, r[Y], v);
    } else
      up(1, 1, n, 1, l[x] - 1, v), up(1, 1, n, r[x] + 1, l[y] - 1, v),
          up(1, 1, n, r[y] + 1, n, v);
    printf("%d\n", n - sum[1]);
  }
  return 0;
}
