#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> e[200005];
int l[200005], r[200005], dep[200005], p[200005][21], dfn;
struct T {
  int v, tag;
} t[200005 << 2];
map<int, map<int, int> > vis;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
    if (ch == -1) return 0;
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void addEdge(int u, int v) { e[u].push_back(v); }
void dfs(int u, int fa) {
  l[u] = ++dfn, dep[u] = dep[fa] + 1, p[u][0] = fa;
  for (int i = 1; i <= 20; i++) p[u][i] = p[p[u][i - 1]][i - 1];
  for (int v : e[u])
    if (v != fa) dfs(v, u);
  r[u] = dfn;
}
void update(int rt, int l, int r, int L, int R, int v) {
  if (L > R) return;
  if (L <= l && r <= R) {
    t[rt].tag += v;
    if (t[rt].tag)
      t[rt].v = r - l + 1;
    else if (l == r)
      t[rt].v = 0;
    else
      t[rt].v = t[(rt << 1)].v + t[(rt << 1 | 1)].v;
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) update((rt << 1), l, mid, L, R, v);
  if (mid < R) update((rt << 1 | 1), mid + 1, r, L, R, v);
  if (t[rt].tag)
    t[rt].v = r - l + 1;
  else
    t[rt].v = t[(rt << 1)].v + t[(rt << 1 | 1)].v;
}
inline int jmp(int u, int v) {
  int x = v;
  for (int i = 20; i >= 0; i--)
    if (dep[p[x][i]] > dep[u]) x = p[x][i];
  return x;
}
int main() {
  n = read(), m = read();
  for (int i = 1, u, v; i < n; i++)
    u = read(), v = read(), addEdge(u, v), addEdge(v, u);
  dfs(1, 0);
  while (m--) {
    int u, v, w;
    u = read(), v = read();
    if (l[u] > l[v]) swap(u, v);
    w = vis[u][v] ? 1 : -1, vis[u][v] ^= 1;
    if (r[u] < r[v])
      update(1, 1, n, 1, l[u] - 1, w), update(1, 1, n, r[u] + 1, l[v] - 1, w),
          update(1, 1, n, r[v] + 1, n, w);
    else {
      int x = jmp(u, v);
      update(1, 1, n, l[x], l[v] - 1, w), update(1, 1, n, r[v] + 1, r[x], w);
    }
    printf("%d\n", n - t[1].v);
  }
  return 0;
}
