#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
vector<int> adj[N];
int pos[N], size[N], lazy[4 * N], now = 0, level[N], ancestor[N][22];
pair<int, int> it[4 * N];
set<pair<int, int> > lis;
void dfs(int x, int p) {
  now++;
  pos[x] = now;
  size[x] = 1;
  int i;
  for (i = 1; i <= 20; i++) {
    ancestor[x][i] = ancestor[ancestor[x][i - 1]][i - 1];
  }
  for (i = 0; i < adj[x].size(); i++) {
    if (adj[x][i] != p) {
      level[adj[x][i]] = level[x] + 1;
      ancestor[adj[x][i]][0] = x;
      dfs(adj[x][i], x);
      size[x] += size[adj[x][i]];
    }
  }
}
int findd(int x, int k) {
  while (k) {
    int y = log2(k);
    x = ancestor[x][y];
    k -= (1 << y);
  }
  return x;
}
void init(int idx, int l, int r) {
  if (l == r) {
    it[idx].second = 1;
    return;
  }
  init(2 * idx, l, (l + r) / 2);
  init(2 * idx + 1, (l + r) / 2 + 1, r);
  it[idx].second = r - l + 1;
}
void upd(int idx, int l, int r, int lef, int rig, int val) {
  if (lef > rig) {
    return;
  }
  if (l > rig || r < lef) {
    return;
  }
  if (l >= lef && r <= rig) {
    it[idx].first += val;
    lazy[idx] += val;
    return;
  }
  if (lazy[idx] != 0) {
    it[2 * idx].first += lazy[idx];
    it[2 * idx + 1].first += lazy[idx];
    lazy[2 * idx] += lazy[idx];
    lazy[2 * idx + 1] += lazy[idx];
    lazy[idx] = 0;
  }
  upd(2 * idx, l, (l + r) / 2, lef, rig, val);
  upd(2 * idx + 1, (l + r) / 2 + 1, r, lef, rig, val);
  if (it[2 * idx].first < it[2 * idx + 1].first) {
    it[idx].first = it[2 * idx].first;
    it[idx].second = it[2 * idx].second;
  }
  if (it[2 * idx].first == it[2 * idx + 1].first) {
    it[idx].first = it[2 * idx].first;
    it[idx].second = it[2 * idx].second + it[2 * idx + 1].second;
  }
  if (it[2 * idx].first > it[2 * idx + 1].first) {
    it[idx].first = it[2 * idx + 1].first;
    it[idx].second = it[2 * idx + 1].second;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, i, j, k, l, q;
  cin >> n >> q;
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    adj[j].push_back(k);
    adj[k].push_back(j);
  }
  dfs(1, 1);
  init(1, 1, n);
  for (i = 1; i <= q; i++) {
    cin >> j >> k;
    if (pos[j] > pos[k]) {
      swap(j, k);
    }
    if (pos[j] + size[j] < pos[k] + size[k]) {
      if (lis.count({j, k})) {
        lis.erase({j, k});
        upd(1, 1, n, 1, pos[j] - 1, -1);
        upd(1, 1, n, pos[j] + size[j], pos[k] - 1, -1);
        upd(1, 1, n, pos[k] + size[k], n, -1);
      } else {
        lis.insert({j, k});
        upd(1, 1, n, 1, pos[j] - 1, 1);
        upd(1, 1, n, pos[j] + size[j], pos[k] - 1, 1);
        upd(1, 1, n, pos[k] + size[k], n, 1);
      }
    } else {
      j = findd(k, level[k] - level[j] - 1);
      if (lis.count({j, k})) {
        lis.erase({j, k});
        upd(1, 1, n, pos[j], pos[k] - 1, -1);
        upd(1, 1, n, pos[k] + size[k], pos[j] + size[j] - 1, -1);
      } else {
        lis.insert({j, k});
        upd(1, 1, n, pos[j], pos[k] - 1, 1);
        upd(1, 1, n, pos[k] + size[k], pos[j] + size[j] - 1, 1);
      }
    }
    if (it[1].first == 0) {
      cout << it[1].second << "\n";
    } else {
      cout << 0 << "\n";
    }
  }
}
