#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 18, inf = 1e9 + 79, logn = 18;
vector<int> tin(maxn), tout(maxn), add(maxn * 2, 0), mini(maxn * 2, inf),
    cnt(maxn * 2, 0), l(maxn * 2, 0), r(maxn * 2, 0), d(maxn, 0);
vector<vector<int> > t(maxn), a(logn, vector<int>(maxn, 0));
int timer = 0, n, q;
void dfs(int v) {
  for (int i = 1; i < logn; i++) a[i][v] = a[i - 1][a[i - 1][v]];
  tin[v] = timer++;
  for (int i : t[v])
    if (i != a[0][v]) a[0][i] = v, d[i] = d[v] + 1, dfs(i);
  tout[v] = timer - 1;
}
int kth_ancestor(int u, int k) {
  for (int i = logn - 1; i >= 0; i--)
    if (k & (1 << i)) u = a[i][u];
  return u;
}
bool is_ancestor(int u, int v) {
  return tin[u] <= tin[v] && tout[v] <= tout[u];
}
void merge(int vr) {
  mini[vr] = min(mini[vr * 2 + 1], mini[vr * 2 + 2]) + add[vr], cnt[vr] = 0;
  if (mini[vr] == mini[vr * 2 + 1]) cnt[vr] += cnt[vr * 2 + 1];
  if (mini[vr] == mini[vr * 2 + 2]) cnt[vr] += cnt[vr * 2 + 2];
}
void unlazy(int vr) {
  mini[vr * 2 + 1] += add[vr], add[vr * 2 + 1] += add[vr];
  mini[vr * 2 + 2] += add[vr], add[vr * 2 + 2] += add[vr];
  add[vr] = 0;
}
void update(int li, int ri, int delta, int vr = 0) {
  if (ri < l[vr] || r[vr] < li) return;
  if (li <= l[vr] && r[vr] <= ri) {
    add[vr] += delta, mini[vr] += delta;
    return;
  }
  unlazy(vr);
  update(li, ri, delta, vr * 2 + 1), update(li, ri, delta, vr * 2 + 2);
  merge(vr);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = maxn - 1; i < maxn * 2; i++) l[i] = r[i] = i - (maxn - 1);
  for (int i = maxn - 2; i >= 0; i--) l[i] = l[i * 2 + 1], r[i] = r[i * 2 + 2];
  for (int i = 0; i < maxn * 2; i++) cnt[i] = r[i] - l[i] + 1;
  int n, q;
  cin >> n >> q;
  for (int i = 0, u, v; i < n - 1; i++) {
    cin >> u >> v;
    t[--u].push_back(--v), t[v].push_back(u);
  }
  update(0, n - 1, -inf);
  dfs(0);
  set<pair<int, int> > s;
  while (q--) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    pair<int, int> p(min(u, v), max(u, v));
    int delta;
    if (s.count(p))
      s.erase(p), delta = -1;
    else
      s.insert(p), delta = 1;
    if (d[u] > d[v]) swap(u, v);
    if (is_ancestor(u, v)) {
      int x = kth_ancestor(v, d[v] - d[u] - 1);
      update(tin[x], tout[x], delta);
      update(tin[v], tout[v], -delta);
    } else {
      update(0, n - 1, delta);
      update(tin[u], tout[u], -delta);
      update(tin[v], tout[v], -delta);
    }
    if (mini[0] == 0)
      cout << cnt[0] << "\n";
    else
      cout << "0\n";
  }
  return 0;
}
