#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const long long MXN = 2e5 + 10;
const long long MXS = MXN * 4;
const long long LOG = 20;
long long n, q, timer, cnt;
long long dis[MXN], Stm[MXN], Ftm[MXN], Tree[MXN];
long long Jad[LOG][MXN];
vector<long long> adj[MXN];
set<pair<long long, long long>> st;
void prep(long long u, long long par) {
  Jad[0][u] = par;
  for (int i = 1; i < LOG; i++) {
    Jad[i][u] = Jad[i - 1][Jad[i - 1][u]];
  }
  Stm[u] = (++timer), Tree[timer] = u;
  for (auto v : adj[u]) {
    if (v == par) continue;
    dis[v] = dis[u] + 1;
    prep(v, u);
  }
  Ftm[u] = timer;
}
inline bool Is_Jad(long long x, long long u) {
  return Stm[x] <= Stm[u] && Ftm[u] <= Ftm[x];
}
long long K_Jad(long long u, long long k) {
  for (int i = 0; i < LOG; i++) {
    if ((k >> i) & 1LL) u = Jad[i][u];
  }
  return u;
}
long long Max[MXS], Ted[MXS], Lazy[MXS];
void Build(long long id = 1, long long s = 1, long long e = n) {
  Ted[id] = (e - s + 1);
  if ((e - s + 1) == 1) return;
  Build((id * 2), s, ((s + e) / 2)), Build((id * 2 + 1), ((s + e) / 2 + 1), e);
}
void Shift(long long id, long long s, long long e) {
  if (!Lazy[id]) return;
  Max[id] += Lazy[id];
  if ((e - s + 1) > 1) {
    Lazy[(id * 2)] += Lazy[id], Lazy[(id * 2 + 1)] += Lazy[id];
  }
  Lazy[id] = 0;
}
void Upd(long long l, long long r, long long x, long long id = 1,
         long long s = 1, long long e = n) {
  Shift(id, s, e);
  if (e < l || s > r) return;
  if (l <= s && e <= r) {
    Lazy[id] += x;
    Shift(id, s, e);
    return;
  }
  Upd(l, r, x, (id * 2), s, ((s + e) / 2)),
      Upd(l, r, x, (id * 2 + 1), ((s + e) / 2 + 1), e);
  Max[id] = Max[(id * 2)], Ted[id] = Ted[(id * 2)];
  if (Max[(id * 2 + 1)] > Max[(id * 2)])
    Ted[id] = Ted[(id * 2 + 1)], Max[id] = Max[(id * 2 + 1)];
  else if (Max[(id * 2 + 1)] == Max[(id * 2)])
    Ted[id] += Ted[(id * 2 + 1)];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  prep(1, 0);
  assert(timer == n);
  Build();
  while (q--) {
    long long u, v, z, d, y;
    cin >> u >> v;
    if (dis[v] < dis[u]) swap(u, v);
    if (dis[u] == dis[v] && u < v) swap(u, v);
    d = dis[v] - dis[u];
    if (st.count({u, v}))
      z = -1;
    else
      z = +1;
    if (!Is_Jad(u, v)) {
      Upd(Stm[u], Ftm[u], z);
      Upd(Stm[v], Ftm[v], z);
    } else {
      y = K_Jad(v, d - 1);
      Upd(1, n, z);
      Upd(Stm[v], Ftm[v], z);
      Upd(Stm[y], Ftm[y], -z);
    }
    cnt += z;
    if (z == -1)
      st.erase({u, v});
    else
      st.insert({u, v});
    if (Max[1] != cnt)
      cout << 0 << '\n';
    else
      cout << Ted[1] << '\n';
  }
  return 0;
}
