#include <bits/stdc++.h>
const size_t maxN = 200005;
const size_t ioSize = 1 << 21;
char iBuf[ioSize], *iS, *iE;
inline char getc() {
  return iS == iE ? iE = iBuf + fread(iS = iBuf, 1, ioSize, stdin),
                    iS == iE ? EOF : *iS++ : *iS++;
}
void readi(int &x) {
  char c;
  for (c = getc(); !isdigit(c); c = getc())
    ;
  x = c ^ '0';
  for (c = getc(); isdigit(c); c = getc()) (x *= 10) += c ^ '0';
}
int Min[1 << 19 | 1], minCnt[1 << 19 | 1], Tag[1 << 19 | 1];
inline void pushup(int i) {
  if (Min[i << 1] < Min[i << 1 | 1])
    Min[i] = Min[i << 1], minCnt[i] = minCnt[i << 1];
  else if (Min[i << 1] > Min[i << 1 | 1])
    Min[i] = Min[i << 1 | 1], minCnt[i] = minCnt[i << 1 | 1];
  else
    Min[i] = Min[i << 1], minCnt[i] = minCnt[i << 1] + minCnt[i << 1 | 1];
}
inline void add(int i, int v) { Min[i] += v, Tag[i] += v; }
inline void pushdown(int i) {
  if (Tag[i]) {
    add(i << 1, Tag[i]);
    add(i << 1 | 1, Tag[i]);
    Tag[i] = 0;
  }
}
void build(int i, int l, int r) {
  if (l == r) {
    Min[i] = 0, minCnt[i] = 1;
    return;
  }
  int m = l + r >> 1;
  build(i << 1, l, m);
  build(i << 1 | 1, m + 1, r);
  pushup(i);
}
void modify(int i, int l, int r, int tl, int tr, int v) {
  if (tl > tr) return;
  if (l >= tl && r <= tr) {
    add(i, v);
    return;
  }
  pushdown(i);
  int m = l + r >> 1;
  if (tl <= m) modify(i << 1, l, m, tl, tr, v);
  if (tr > m) modify(i << 1 | 1, m + 1, r, tl, tr, v);
  pushup(i);
}
int N, Q;
std::vector<int> G[maxN];
int DFN[maxN], Index, Size[maxN];
std::set<std::pair<int, int>> E;
void DFS(int i, int f) {
  DFN[i] = ++Index;
  Size[i] = 1;
  for (auto to : G[i])
    if (to != f) {
      DFS(to, i);
      Size[i] += Size[to];
    }
  if (f) G[i].erase(std::find(G[i].begin(), G[i].end(), f));
}
int main() {
  std::srand((size_t) new char);
  readi(N), readi(Q);
  for (int u, v, i = 1; i != N; ++i) {
    readi(u), readi(v);
    G[u].push_back(v), G[v].push_back(u);
  }
  DFS(std::rand() % N + 1, 0);
  build(1, 1, N);
  for (int u, v; Q--;) {
    readi(u), readi(v);
    if (DFN[u] > DFN[v]) std::swap(u, v);
    auto it = E.find(std::make_pair(u, v));
    int val;
    if (it == E.end())
      val = 1, E.emplace(u, v);
    else
      val = -1, E.erase(it);
    if (DFN[v] < DFN[u] + Size[u]) {
      int t = *(std::lower_bound(G[u].begin(), G[u].end(), v,
                                 [](int x, int y) { return DFN[x] < DFN[y]; }) -
                1);
      modify(1, 1, N, DFN[t], DFN[v] - 1, val);
      modify(1, 1, N, DFN[v] + Size[v], DFN[t] + Size[t] - 1, val);
    } else {
      modify(1, 1, N, 1, DFN[u] - 1, val);
      modify(1, 1, N, DFN[u] + Size[u], DFN[v] - 1, val);
      modify(1, 1, N, DFN[v] + Size[v], N, val);
    }
    printf("%d\n", Min[1] == 0 ? minCnt[1] : 0);
  }
  return 0;
}
