#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
vector<vector<long long>> d;
vector<long long> pre, post;
long long id = 0;
vector<long long> par;
void dfs(long long v, long long oj) {
  par[v] = oj;
  pre[v] = id;
  id++;
  for (long long i = (0); i <= ((long long)(((long long)(d[v]).size())) - 1);
       i++) {
    if (d[v][i] == oj) {
      swap(d[v][i], d[v].back());
      i--;
      d[v].pop_back();
    } else {
      dfs(d[v][i], v);
    }
  }
  post[v] = id;
}
vector<long long> dp, ak;
long long nn = 1;
void licz(long long nr) {
  if (ak[nr] == 0) {
    if (nr >= nn) {
      dp[nr] = 1;
    } else {
      dp[nr] = dp[nr * 2] + dp[nr * 2 + 1];
    }
  } else {
    dp[nr] = 0;
  }
}
long long n, q;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  cin >> n >> q;
  d.resize(n);
  pre.resize(n);
  post.resize(n);
  par.resize(n);
  vector<long long> p;
  for (long long i = (0); i <= ((long long)(n)-1); i++) p.push_back(i);
  random_shuffle((p).begin(), (p).end());
  for (long long i = (0); i <= ((long long)(n - 1) - 1); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    a = p[a];
    b = p[b];
    d[a].push_back(b);
    d[b].push_back(a);
  }
  dfs(0, -1);
  (pre, post);
  while (nn <= n) nn *= 2;
  dp.resize(nn * 2);
  ak.resize(nn * 2);
  for (long long i = (0); i <= ((long long)(nn)-1); i++) {
    if (i < n) {
      dp[i + nn] = 1;
    } else {
      ak[i + nn] = 1;
    }
  }
  for (long long i = nn - 1; i >= 1; i--) {
    dp[i] = dp[i * 2] + dp[i * 2 + 1];
  }
  (dp[1]);
  set<pair<long long, long long>> secik;
  for (long long i = (0); i <= ((long long)(q)-1); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    a = p[a];
    b = p[b];
    if (pre[a] > pre[b]) swap(a, b);
    long long mn = 1;
    auto xxx = secik.find({a, b});
    if (xxx != secik.end()) {
      secik.erase({a, b});
      mn = -1;
    } else {
      secik.insert({a, b});
    }
    vector<pair<long long, long long>> prze;
    if (post[a] <= pre[b]) {
      prze.push_back({0, pre[a]});
      prze.push_back({post[a], pre[b]});
      prze.push_back({post[b], n});
    } else {
      long long po = 0, ko = ((long long)(d[a]).size());
      (d[a]);
      while (1) {
        long long m = d[a][(po + ko) / 2];
        (pre[m], pre[b], post[m], post[b]);
        if (pre[m] <= pre[b]) {
          if (post[m] >= post[b]) {
            prze.push_back({pre[m], pre[b]});
            prze.push_back({post[b], post[m]});
            break;
          } else {
            po = (po + ko) / 2;
          }
        } else {
          ko = (po + ko) / 2;
        }
      }
    }
    long long po;
    long long ko;
    function<void(long long, long long, long long)> add =
        [&](long long nr, long long beg, long long en) {
          if (beg >= ko || po >= en) return;
          if (po <= beg && en <= ko) {
            ak[nr] += mn;
            licz(nr);
            return;
          }
          add(nr * 2, beg, (beg + en) / 2);
          add(nr * 2 + 1, (beg + en) / 2, en);
          licz(nr);
        };
    (prze, mn);
    for (pair<long long, long long> el : prze) {
      po = el.first;
      ko = el.second;
      add(1, 0, nn);
    }
    cout << dp[1] << "\n";
  }
}
