#include <bits/stdc++.h>
using namespace std;
map<int, int> M[200009];
int n, Q, edges, cnt;
int hd[200009], to[200009 << 1], nex[200009 << 1], dep[200009], fa[19][200009],
    size[200009], dfn[200009], ed[200009];
struct data {
  int l, r, sum, len;
} s[200009 << 2];
void add(int u, int v) { nex[++edges] = hd[u], hd[u] = edges, to[edges] = v; }
void dfs(int x, int ff) {
  dep[x] = dep[ff] + 1;
  fa[0][x] = ff;
  dfn[x] = ++cnt, size[x] = 1;
  for (int i = 1; i < 19; ++i) {
    fa[i][x] = fa[i - 1][fa[i - 1][x]];
  }
  for (int i = hd[x]; i; i = nex[i]) {
    int v = to[i];
    if (v == ff) continue;
    dfs(v, x), size[x] += size[v];
  }
  ed[x] = cnt;
}
void build(int l, int r, int now) {
  s[now].l = l, s[now].r = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, now << 1), build(mid + 1, r, now << 1 | 1);
}
void pushup(int now) {
  if (s[now].sum > 0)
    s[now].len = s[now].r - s[now].l + 1;
  else if (s[now].l == s[now].r)
    s[now].len = 0;
  else
    s[now].len = s[now << 1].len + s[now << 1 | 1].len;
}
void update(int l, int r, int now, int L, int R, int v) {
  if (L > R) return;
  if (l >= L && r <= R) {
    s[now].sum += v;
    pushup(now);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) update(l, mid, now << 1, L, R, v);
  if (R > mid) update(mid + 1, r, now << 1 | 1, L, R, v);
  pushup(now);
}
int jump(int x, int y) {
  for (int i = 18; i >= 0; --i) {
    if (dep[fa[i][y]] > dep[x]) y = fa[i][y];
  }
  return y;
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  dfs(1, 0), build(1, n, 1);
  for (int i = 1; i <= Q; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (dfn[x] > dfn[y]) swap(x, y);
    if (ed[x] >= ed[y]) {
      int son = jump(x, y);
      if (M[x][y] == 0) {
        M[x][y] = 1;
        update(1, n, 1, dfn[son], dfn[y] - 1, 1);
        update(1, n, 1, ed[y] + 1, ed[son], 1);
      } else {
        M[x][y] = 0;
        update(1, n, 1, dfn[son], dfn[y] - 1, -1);
        update(1, n, 1, ed[y] + 1, ed[son], -1);
      }
    } else {
      if (M[x][y] == 0) {
        M[x][y] = 1;
        update(1, n, 1, 1, dfn[x] - 1, 1);
        update(1, n, 1, ed[x] + 1, dfn[y] - 1, 1);
        update(1, n, 1, ed[y] + 1, n, 1);
      } else {
        M[x][y] = 0;
        update(1, n, 1, 1, dfn[x] - 1, -1);
        update(1, n, 1, ed[x] + 1, dfn[y] - 1, -1);
        update(1, n, 1, ed[y] + 1, n, -1);
      }
    }
    printf("%d\n", n - s[1].len);
  }
  return 0;
}
