#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
struct Segment_tree {
  int sumv[maxn << 3], cov[maxn << 3];
  inline void pushup(int p, int l, int r) {
    if (cov[p])
      sumv[p] = r - l + 1;
    else
      sumv[p] = sumv[(p << 1)] + sumv[(p << 1 | 1)];
  }
  inline void Add(int p, int l, int r, int ql, int qr, int V) {
    if (ql <= l && qr >= r) {
      cov[p] += V;
      pushup(p, l, r);
      return;
    }
    int mid = (l + r) >> 1;
    if (ql <= mid) Add((p << 1), l, mid, ql, qr, V);
    if (qr > mid) Add((p << 1 | 1), mid + 1, r, ql, qr, V);
    pushup(p, l, r);
  }
  inline int getans() { return sumv[1]; }
} seg;
int head[maxn], nxt[maxn << 1], ver[maxn << 1], tot;
inline void addedge(int a, int b) {
  nxt[++tot] = head[a];
  ver[tot] = b;
  head[a] = tot;
  nxt[++tot] = head[b];
  ver[tot] = a;
  head[b] = tot;
}
int size[maxn], hson[maxn], dep[maxn], fa[maxn];
inline void dfs1(int x, int fat) {
  size[x] = 1;
  dep[x] = dep[fat] + 1;
  fa[x] = fat;
  int maxsize = 0;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == fat) continue;
    dfs1(y, x);
    size[x] += size[y];
    if (size[y] > maxsize) maxsize = size[y], hson[x] = y;
  }
}
int top[maxn], id[maxn], id_cnt;
inline void dfs2(int x, int Top) {
  top[x] = Top;
  id[x] = ++id_cnt;
  if (hson[x]) dfs2(hson[x], Top);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == fa[x] || y == hson[x]) continue;
    dfs2(y, y);
  }
}
int F[maxn][21];
set<pair<int, int> > S;
int n, m;
inline void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), addedge(a, b);
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; i++) F[i][0] = fa[i];
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i <= n; i++) F[i][j] = F[F[i][j - 1]][j - 1];
}
inline int Climb(int x, int upv) {
  for (int i = 0; upv; upv >>= 1, i++)
    if (upv & 1) x = F[x][i];
  return x;
}
inline int lca(int a, int b) {
  while (top[a] != top[b]) {
    if (dep[top[a]] < dep[top[b]]) swap(a, b);
    a = fa[top[a]];
  }
  return dep[a] < dep[b] ? a : b;
}
inline void Add(int a, int b, int v) {
  int t = lca(a, b);
  if (t != a && t != b) {
    if (id[a] > id[b]) swap(a, b);
    if (id[a] > 1) seg.Add(1, 1, n, 1, id[a] - 1, v);
    if (id[a] + size[a] <= id[b] - 1)
      seg.Add(1, 1, n, id[a] + size[a], id[b] - 1, v);
    if (id[b] + size[b] - 1 < n) seg.Add(1, 1, n, id[b] + size[b], n, v);
  } else {
    if (t == b) swap(a, b);
    int rt = Climb(b, dep[b] - dep[a] - 1);
    int L = id[rt], R = id[rt] + size[rt] - 1;
    if (id[b] > L) seg.Add(1, 1, n, L, id[b] - 1, v);
    if (id[b] + size[b] < R) seg.Add(1, 1, n, id[b] + size[b], R, v);
  }
}
int main() {
  init();
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    if (S.count(make_pair(u, v)) == 0)
      Add(u, v, 1), S.insert(make_pair(u, v));
    else
      Add(u, v, -1), S.erase(make_pair(u, v));
    printf("%d\n", n - seg.getans());
  }
}
