#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1e9 + 100;
const long long LINF = 1e18 + 100;
struct node {
  int mn, mincnt, lz;
};
int n, q;
vector<int> adj[200100];
set<pair<int, int> > edge;
int par[30][200100];
int sttime[200100], fntime[200100], timer, h[200100];
void dfs(int v) {
  sttime[v] = timer++;
  for (int u : adj[v]) {
    if (u == par[0][v]) continue;
    par[0][u] = v;
    h[u] = h[v] + 1;
    dfs(u);
  }
  fntime[v] = timer;
}
int getpar(int v, int x) {
  for (int i = (0); i < (30); i++)
    if (x >> i & 1) v = par[i][v];
  return v;
}
node seg[4 * 200100];
void pushdown(int v) {
  if (!seg[v].lz) return;
  for (int i = (0); i < (2); i++)
    seg[2 * v + i].mn += seg[v].lz, seg[2 * v + i].lz += seg[v].lz;
  seg[v].lz = 0;
}
void add(int L, int R, int x, int v = 1, int l = 0, int r = n - 1) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    seg[v].mn += x;
    seg[v].lz += x;
    return;
  }
  int mid = (r + l) / 2;
  pushdown(v);
  add(L, R, x, 2 * v, l, mid);
  add(L, R, x, 2 * v + 1, mid + 1, r);
  seg[v].mn = min(seg[2 * v].mn, seg[2 * v + 1].mn);
  seg[v].mincnt = 0;
  for (int i = (0); i < (2); i++)
    if (seg[2 * v + i].mn == seg[v].mn) seg[v].mincnt += seg[2 * v + i].mincnt;
}
void build(int v = 1, int l = 0, int r = n - 1) {
  seg[v].mincnt = r - l + 1;
  if (l == r) return;
  int mid = (r + l) / 2;
  build(2 * v, l, mid);
  build(2 * v + 1, mid + 1, r);
}
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> q;
  for (int i = (0); i < (n - 1); i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1);
  for (int i = (1); i < (30); i++)
    for (int j = (1); j < (n + 1); j++) par[i][j] = par[i - 1][par[i - 1][j]];
  build();
  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    int p = -1;
    if (edge.find({x, y}) != edge.end())
      edge.erase({x, y});
    else {
      edge.insert({x, y});
      p = 1;
    }
    if (sttime[x] > sttime[y]) swap(x, y);
    if (fntime[y] <= fntime[x]) {
      x = getpar(y, h[y] - h[x] - 1);
      add(sttime[x], sttime[y] - 1, p);
      add(fntime[y], fntime[x] - 1, p);
    } else {
      add(0, sttime[x] - 1, p);
      add(fntime[x], sttime[y] - 1, p);
      add(fntime[y], n - 1, p);
    }
    if (seg[1].mn > 0)
      cout << "0\n";
    else
      cout << seg[1].mincnt << '\n';
  }
  return 0;
}
