#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, inf = 1e18;
long long n, q, tmp1, tmp2, seg[4 * N], mn[4 * N], h[N], par[N][30], st[N],
    ft[N], tim, V, lazy[4 * N];
vector<long long> adj[N];
map<long long, bool> mp[N];
void Build(long long id, long long L, long long R) {
  long long mid = (L + R) / 2;
  if (R - L < 2) {
    seg[id] = 1;
    return;
  }
  Build(2 * id, L, mid);
  Build(2 * id + 1, mid, R);
  seg[id] = seg[2 * id] + seg[2 * id + 1];
}
void relax(long long id) {
  mn[2 * id] += lazy[id];
  mn[2 * id + 1] += lazy[id];
  lazy[2 * id] += lazy[id];
  lazy[2 * id + 1] += lazy[id];
  lazy[id] = 0;
}
void ADD(long long s, long long e, long long id, long long L, long long R,
         long long val) {
  if (s == e) return;
  long long mid = (L + R) / 2;
  if (s <= L && R <= e) {
    mn[id] += val;
    lazy[id] += val;
    return;
  }
  if (e <= L || R <= s) {
    return;
  }
  relax(id);
  ADD(s, e, 2 * id, L, mid, val);
  ADD(s, e, 2 * id + 1, mid, R, val);
  mn[id] = min(mn[2 * id], mn[2 * id + 1]);
  seg[id] = 0;
  if (mn[id] == mn[2 * id]) seg[id] += seg[2 * id];
  if (mn[id] == mn[2 * id + 1]) seg[id] += seg[2 * id + 1];
}
void DFS(long long v, long long p, long long hi) {
  st[v] = tim++;
  h[v] = hi;
  par[v][0] = p;
  for (long long j = 1; j < 20; j++) par[v][j] = par[par[v][j - 1]][j - 1];
  for (auto u : adj[v])
    if (u != p) DFS(u, v, hi + 1);
  ft[v] = tim;
}
long long kthpar(long long v, long long k) {
  for (long long j = 0; j < 20; j++)
    if (k & (1 << j)) v = par[v][j];
  return (v);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (long long i = 1; i < n; i++) {
    cin >> tmp1 >> tmp2;
    adj[tmp1].push_back(tmp2);
    adj[tmp2].push_back(tmp1);
  }
  DFS(1, 0, 0);
  Build(1, 0, n);
  for (long long i = 1; i <= q; i++) {
    cin >> tmp1 >> tmp2;
    if (tmp2 < tmp1) swap(tmp1, tmp2);
    if (mp[tmp1][tmp2] == true)
      V = -1;
    else
      V = 1;
    mp[tmp1][tmp2] ^= 1;
    if (st[tmp1] > st[tmp2]) swap(tmp1, tmp2);
    if ((st[tmp1] < st[tmp2] && st[tmp2] < ft[tmp1])) {
      tmp1 = kthpar(tmp2, h[tmp2] - h[tmp1] - 1);
      ADD(st[tmp1], st[tmp2], 1, 0, n, V);
      ADD(ft[tmp2], ft[tmp1], 1, 0, n, V);
    } else {
      ADD(0, st[tmp1], 1, 0, n, V);
      ADD(ft[tmp1], st[tmp2], 1, 0, n, V);
      ADD(ft[tmp2], n, 1, 0, n, V);
    }
    if (mn[1] != 0) {
      cout << 0 << endl;
      continue;
    }
    cout << seg[1] << endl;
  }
  return 0;
}
