#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return l + rng() % (r - l + 1); }
const int N = 200010;
int n, q, it;
int tin[N], tout[N], ind[N];
int M[N * 4], T[N * 4], B[N * 4];
int f[N][22];
vector<int> ad[N];
map<pair<int, int>, int> mp;
void dfs(int u, int p = -1) {
  tin[u] = ++it;
  ind[it] = u;
  for (int i = 1, _c = 20; i <= _c; ++i) f[u][i] = f[f[u][i - 1]][i - 1];
  for (auto& v : ad[u])
    if (v != p) {
      f[v][0] = u;
      dfs(v, u);
    }
  tout[u] = it;
}
int anc(int u, int v) { return tin[u] <= tin[v] && tout[u] >= tout[v] || !u; }
void mrg(int s) {
  M[s] = max(M[2 * s], M[2 * s + 1]);
  T[s] = 0;
  if (M[s] == M[2 * s]) T[s] += T[2 * s];
  if (M[s] == M[2 * s + 1]) T[s] += T[2 * s + 1];
}
void trans(int s) {
  if (!B[s]) return;
  M[s * 2] += B[s];
  M[2 * s + 1] += B[s];
  B[s * 2] += B[s];
  B[2 * s + 1] += B[s];
  B[s] = 0;
}
void upd(int s, int l, int r, int u, int v, int x) {
  if (l > v || u > r || u > v) return;
  if (u <= l && r <= v) {
    M[s] += x;
    B[s] += x;
    return;
  }
  trans(s);
  int m = (l + r) / 2;
  upd(2 * s, l, m, u, v, x);
  upd(2 * s + 1, m + 1, r, u, v, x);
  mrg(s);
}
void build(int s, int l, int r) {
  if (l == r) {
    T[s] = 1;
    return;
  }
  int m = (l + r) / 2;
  build(2 * s, l, m);
  build(2 * s + 1, m + 1, r);
  mrg(s);
}
int main() {
  n = ({
    int x = 0;
    int c = getchar(), n = 0;
    for (; !isdigit(c); c = getchar()) n = (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  q = ({
    int x = 0;
    int c = getchar(), n = 0;
    for (; !isdigit(c); c = getchar()) n = (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    n ? -x : x;
  });
  for (int i = 2, _c = n; i <= _c; ++i) {
    int u = ({
      int x = 0;
      int c = getchar(), n = 0;
      for (; !isdigit(c); c = getchar()) n = (c == '-');
      for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
      n ? -x : x;
    }),
        v = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        });
    ad[u].push_back(v);
    ad[v].push_back(u);
  }
  dfs(1);
  build(1, 1, n);
  for (int i = 1, _c = q; i <= _c; ++i) {
    int u = ({
      int x = 0;
      int c = getchar(), n = 0;
      for (; !isdigit(c); c = getchar()) n = (c == '-');
      for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
      n ? -x : x;
    }),
        v = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        });
    if (u > v) swap(u, v);
    int c = mp[{u, v}] ? -1 : 1;
    if (anc(v, u)) swap(u, v);
    if (anc(u, v)) {
      int p = v;
      for (int i = 20, _c = 0; i >= _c; --i)
        if (!anc(f[p][i], u)) p = f[p][i];
      upd(1, 1, n, tin[p], tout[p], -c);
      upd(1, 1, n, tin[v], tout[v], c);
    } else {
      upd(1, 1, n, 1, n, -c);
      upd(1, 1, n, tin[u], tout[u], c);
      upd(1, 1, n, tin[v], tout[v], c);
    }
    cout << (M[1] == 0 ? T[1] : 0) << "\n";
    if (u > v) swap(u, v);
    mp[{u, v}] ^= 1;
  }
}
