#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = INT_MAX;
const long long inff = 1e18;
const long long mod = 1e9 + 7;
int n, q, x, y;
vector<int> G[maxn];
int L[maxn], R[maxn], p[maxn][22], depth[maxn], cnt = 1;
int seg[maxn * 4], tag[maxn * 4], num[maxn * 4];
set<pair<int, int> > s;
void dfs(int now, int pp) {
  L[now] = cnt++;
  p[now][0] = pp;
  for (int i : G[now])
    if (i != pp) {
      depth[i] = depth[now] + 1;
      dfs(i, now);
    }
  R[now] = cnt - 1;
}
void buildlca() {
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n; i++) {
      if (p[i][j - 1] == -1)
        p[i][j] = -1;
      else
        p[i][j] = p[p[i][j - 1]][j - 1];
    }
  }
}
int findlca(int c, int X) {
  for (int i = 0; i <= 20; i++)
    if (X & (1 << i)) c = p[c][i];
  return c;
}
pair<int, int> lca(int c, int d) {
  if (depth[c] < depth[d]) swap(c, d);
  int cc = c, tmp = 0;
  for (int i = 0; i <= 20; i++)
    if ((depth[c] - depth[d]) & (1 << i)) c = p[c][i], tmp += (1 << i);
  if (c == d) return make_pair(c, findlca(cc, tmp - 1));
  for (int i = 20; i >= 0; i--)
    if (p[c][i] != p[d][i]) c = p[c][i], d = p[d][i];
  return make_pair(p[d][0], -1);
}
void Build(int now, int l, int r) {
  num[now] = r - l + 1;
  if (l == r) return;
  int m = (l + r) >> 1;
  Build(now * 2, l, m);
  Build(now * 2 + 1, m + 1, r);
}
void pull(int now) {
  if (seg[now * 2] == seg[now * 2 + 1]) {
    seg[now] = seg[now * 2];
    num[now] = num[now * 2] + num[now * 2 + 1];
  } else if (seg[now * 2] < seg[now * 2 + 1]) {
    seg[now] = seg[now * 2 + 1];
    num[now] = num[now * 2 + 1];
  } else {
    seg[now] = seg[now * 2];
    num[now] = num[now * 2];
  }
}
void push(int now, int l, int r) {
  if (tag[now] == 0 || l == r)
    ;
  else {
    seg[now * 2] += tag[now];
    tag[now * 2] += tag[now];
    seg[now * 2 + 1] += tag[now];
    tag[now * 2 + 1] += tag[now];
  }
  tag[now] = 0;
}
void modify(int now, int l, int r, int ql, int qr, int v) {
  if (r < ql || l > qr)
    return;
  else if (l >= ql && r <= qr) {
    tag[now] += v;
    seg[now] += v;
    return;
  }
  int m = (l + r) >> 1;
  push(now, l, r);
  modify(now * 2, l, m, ql, qr, v);
  modify(now * 2 + 1, m + 1, r, ql, qr, v);
  pull(now);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, -1);
  buildlca();
  Build(1, 1, n);
  while (q--) {
    cin >> x >> y;
    if (x > y) swap(x, y);
    if (s.find(make_pair(x, y)) == s.end()) {
      pair<int, int> ret = lca(x, y);
      if (ret.first == x) {
        modify(1, 1, n, 1, n, 1);
        modify(1, 1, n, L[ret.second], R[ret.second], -1);
        modify(1, 1, n, L[y], R[y], 1);
      } else if (ret.first == y) {
        modify(1, 1, n, 1, n, 1);
        modify(1, 1, n, L[ret.second], R[ret.second], -1);
        modify(1, 1, n, L[x], R[x], 1);
      } else {
        modify(1, 1, n, L[y], R[y], 1);
        modify(1, 1, n, L[x], R[x], 1);
      }
      s.insert(make_pair(x, y));
    } else {
      pair<int, int> ret = lca(x, y);
      if (ret.first == x) {
        modify(1, 1, n, 1, n, -1);
        modify(1, 1, n, L[ret.second], R[ret.second], 1);
        modify(1, 1, n, L[y], R[y], -1);
      } else if (ret.first == y) {
        modify(1, 1, n, 1, n, -1);
        modify(1, 1, n, L[ret.second], R[ret.second], 1);
        modify(1, 1, n, L[x], R[x], -1);
      } else {
        modify(1, 1, n, L[y], R[y], -1);
        modify(1, 1, n, L[x], R[x], -1);
      }
      s.erase(make_pair(x, y));
    }
    if (seg[1] != ((int)(s).size()))
      cout << 0 << '\n';
    else
      cout << num[1] << '\n';
  }
}
