#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 998244353;
const int inf = 1e9;
int n, m;
int par[maxn][20], h[maxn];
vector<int> g[maxn];
int st[maxn], pos[maxn], tim, timer, in[maxn], out[maxn];
void dfs(int v) {
  timer++;
  in[v] = timer;
  for (int i = 1; (1 << i) <= h[v]; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  st[v] = 1;
  for (auto u : g[v])
    if (u != par[v][0]) {
      par[u][0] = v;
      h[u] = h[v] + 1;
      dfs(u);
      st[v] += st[u];
    }
  timer++;
  out[v] = timer;
  tim++;
  pos[v] = tim;
}
int get_par(int v, int he) {
  int i = 0;
  while (he) {
    if (he & 1) v = par[v][i];
    i++;
    he >>= 1;
  }
  return v;
}
int seg[4 * maxn], num[4 * maxn], la[4 * maxn];
void build(int v = 1, int tl = 1, int tr = n) {
  num[v] = tr - tl + 1;
  if (tl == tr) return;
  int tm = (tl + tr) >> 1;
  build(v << 1, tl, tm);
  build(v << 1 | 1, tm + 1, tr);
}
void shift(int v) {
  seg[v] += la[v];
  if (2 * v + 1 < 4 * maxn) {
    la[v << 1] += la[v];
    la[v << 1 | 1] += la[v];
  }
  la[v] = 0;
}
void up(int l, int r, int val, int v = 1, int tl = 1, int tr = n) {
  if (tl == l && tr == r) {
    la[v] += val;
    shift(v);
    return;
  }
  shift(v);
  if (l > r) return;
  int tm = (tl + tr) >> 1;
  up(l, min(tm, r), val, v << 1, tl, tm);
  up(max(tm + 1, l), r, val, v << 1 | 1, tm + 1, tr);
  if (seg[2 * v] > seg[2 * v + 1]) {
    seg[v] = seg[2 * v + 1];
    num[v] = num[2 * v + 1];
    return;
  }
  if (seg[2 * v + 1] > seg[2 * v]) {
    seg[v] = seg[2 * v];
    num[v] = num[2 * v];
    return;
  }
  seg[v] = seg[2 * v];
  num[v] = num[2 * v] + num[2 * v + 1];
}
pair<int, int> qu(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (l > r) return {inf, inf};
  shift(v);
  if (tl == l && tr == r) return {seg[v], num[v]};
  int tm = (tl + tr) >> 1;
  pair<int, int> X = qu(l, min(tm, r), v << 1, tl, tm);
  pair<int, int> Y = qu(max(tm + 1, l), r, v << 1 | 1, tm + 1, tr);
  if (X.first < Y.first) return X;
  if (X.first > Y.first) return Y;
  return {X.first, X.first + Y.first};
}
bool is_anc(int v, int u) {
  if (in[v] <= in[u] && out[v] >= out[u]) return 1;
  return 0;
}
map<int, int> mp[maxn];
int main() {
  cin >> n;
  int q;
  cin >> q;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  build();
  dfs(1);
  while (q--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    int x;
    if (mp[u][v])
      x = -1;
    else
      x = 1;
    mp[u][v] = 1 - mp[u][v];
    if (is_anc(v, u) || is_anc(u, v)) {
      if (h[v] > h[u]) swap(u, v);
      v = get_par(u, h[u] - h[v] - 1);
      up(pos[u] - st[u] + 1, pos[u], -x);
      up(pos[v] - st[v] + 1, pos[v], x);
    } else {
      up(1, n, x);
      up(pos[u] - st[u] + 1, pos[u], -x);
      up(pos[v] - st[v] + 1, pos[v], -x);
    }
    pair<int, int> X = qu(1, n);
    if (X.first == 0)
      cout << X.second << "\n";
    else
      cout << 0 << "\n";
  }
}
