#include <bits/stdc++.h>
using namespace std;
const int maxn = (5e5) + 10, mod = 1e9 + 7;
int n, q, ti, st[maxn], ft[maxn], num[4 * maxn], cnt[4 * maxn], h[maxn],
    spar[21][maxn], lz[4 * maxn];
vector<int> G[maxn];
map<pair<int, int>, bool> mrk_edg;
void pre_DFS(int v, int p) {
  h[v] = h[p] + 1;
  st[v] = ti++;
  spar[0][v] = p;
  for (int lg = 1; lg <= 20; lg++) spar[lg][v] = spar[lg - 1][spar[lg - 1][v]];
  for (auto u : G[v])
    if (u != p) pre_DFS(u, v);
  ft[v] = ti;
}
int get_par(int v, int wh) {
  for (int lg = 20; lg >= 0; lg--)
    if (wh >= (1 << lg)) {
      wh -= (1 << lg);
      v = spar[lg][v];
    }
  return v;
}
void mer(int id) {
  if (num[2 * id] == num[2 * id + 1]) {
    num[id] = num[2 * id];
    cnt[id] = cnt[2 * id] + cnt[2 * id + 1];
  } else if (num[2 * id] <= num[2 * id + 1]) {
    num[id] = num[2 * id];
    cnt[id] = cnt[2 * id];
  } else if (num[2 * id] > num[2 * id + 1]) {
    num[id] = num[2 * id + 1];
    cnt[id] = cnt[2 * id + 1];
  }
}
void build(int s = 0, int e = n, int id = 1) {
  if (s == e - 1) {
    num[id] = 0;
    cnt[id] = 1;
    return;
  }
  int mid = (s + e) >> 1;
  build(s, mid, 2 * id);
  build(mid, e, 2 * id + 1);
  mer(id);
}
void shift(int id) {
  lz[2 * id] += lz[id];
  lz[2 * id + 1] += lz[id];
  num[2 * id] += lz[id];
  num[2 * id + 1] += lz[id];
  lz[id] = 0;
}
void upd(int l, int r, int x, int s = 0, int e = n, int id = 1) {
  if (e <= l || r <= s) return;
  if (l <= s && e <= r) {
    num[id] += x;
    lz[id] += x;
    return;
  }
  int mid = (s + e) >> 1;
  shift(id);
  upd(l, r, x, s, mid, 2 * id);
  upd(l, r, x, mid, e, 2 * id + 1);
  mer(id);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  build();
  pre_DFS(1, 0);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (!mrk_edg[make_pair(min(x, y), max(x, y))]) {
      mrk_edg[make_pair(min(x, y), max(x, y))] = 1;
      if (h[x] > h[y]) swap(x, y);
      if (st[x] <= st[y] && ft[y] <= ft[x]) {
        int res = get_par(y, h[y] - h[x] - 1);
        upd(st[res], ft[res], 1);
        upd(st[y], ft[y], -1);
      } else {
        upd(st[1], ft[1], 1);
        upd(st[x], ft[x], -1);
        upd(st[y], ft[y], -1);
      }
    } else {
      mrk_edg[make_pair(min(x, y), max(x, y))] = 0;
      if (h[x] > h[y]) swap(x, y);
      if (st[x] <= st[y] && ft[y] <= ft[x]) {
        int res = get_par(y, h[y] - h[x] - 1);
        upd(st[res], ft[res], -1);
        upd(st[y], ft[y], 1);
      } else {
        upd(st[1], ft[1], -1);
        upd(st[x], ft[x], 1);
        upd(st[y], ft[y], 1);
      }
    }
    int ans = 0;
    if (!num[1]) ans = cnt[1];
    printf("%d\n", ans);
  }
  return 0;
}
