#include <bits/stdc++.h>
using namespace std;
int n, q, tot, num, ver[400005], nxt[400005], head[200005], d[200005],
    lg[200005], dfn[200005], sz[200005], mn[800005], t[800005], lz[800005],
    f[20][200005];
set<pair<int, int> > s;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = (x + (x << 2) << 1) + (ch ^ 48);
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
}
void add(int x, int y) { ver[++tot] = y, nxt[tot] = head[x], head[x] = tot; }
void dfs(int x) {
  sz[x] = 1, dfn[x] = ++num;
  for (int i = 1; i <= lg[d[x]]; i++) f[i][x] = f[i - 1][f[i - 1][x]];
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != f[0][x]) d[y] = d[x] + 1, f[0][y] = x, dfs(y), sz[x] += sz[y];
  }
}
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  for (int i = lg[d[x] - d[y]]; i >= 0; i--)
    if (d[f[i][x]] > d[y]) x = f[i][x];
  if (f[0][x] == y) return x;
  if (d[x] > d[y]) x = f[0][x];
  for (int i = lg[d[x]]; i >= 0; i--)
    if (f[i][x] != f[i][y]) x = f[i][x], y = f[i][y];
  return f[0][x];
}
void build(int i, int l, int r) {
  t[i] = r - l + 1;
  if (l == r) return;
  int mid = l + r >> 1;
  build(i << 1, l, mid), build(i << 1 | 1, mid + 1, r);
}
void psd(int i, int l, int r) {
  if (lz[i]) {
    int mid = l + r >> 1, li = i << 1, ri = li | 1;
    mn[li] += lz[i], lz[li] += lz[i], mn[ri] += lz[i], lz[ri] += lz[i],
        lz[i] = 0;
  }
}
void add(int i, int l, int r, int x, int y, int z) {
  if (x <= l && y >= r) {
    mn[i] += z, lz[i] += z;
    return;
  }
  psd(i, l, r);
  int mid = l + r >> 1, li = i << 1, ri = li | 1;
  if (x <= mid) add(li, l, mid, x, y, z);
  if (y > mid) add(ri, mid + 1, r, x, y, z);
  mn[i] = min(mn[li], mn[ri]),
  t[i] = (mn[i] == mn[li] ? t[li] : 0) + (mn[i] == mn[ri] ? t[ri] : 0);
}
int main() {
  n = read(), q = read();
  for (int i = 2; i <= n; i++) {
    int x = read(), y = read();
    add(x, y), add(y, x), lg[i] = lg[i >> 1] + 1;
  }
  d[1] = 1, dfs(1), build(1, 1, n);
  while (q--) {
    int x = read(), y = read(), z = lca(x, y), fl;
    if (x > y) swap(x, y);
    set<pair<int, int> >::iterator it = s.lower_bound(make_pair(x, y));
    if (it == s.end() || *it != make_pair(x, y))
      fl = 1, s.insert(make_pair(x, y));
    else
      fl = -1, s.erase(it);
    if (d[x] > d[y]) swap(x, y);
    if (d[z] <= d[x])
      add(1, 1, n, 1, n, fl), add(1, 1, n, dfn[x], dfn[x] + sz[x] - 1, -fl);
    else
      add(1, 1, n, dfn[z], dfn[z] + sz[z] - 1, fl);
    add(1, 1, n, dfn[y], dfn[y] + sz[y] - 1, -fl), write(mn[1] == 0 ? t[1] : 0),
        putchar('\n');
  }
  return 0;
}
