#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int u, v, n, m, q, t, ans;
int cnt[N];
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    cnt[u]++;
    if (cnt[u] == 1) ans++;
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%d", &u, &v);
      if (u > v) swap(u, v);
      cnt[u]++;
      if (cnt[u] == 1) ans++;
    } else if (t == 2) {
      scanf("%d%d", &u, &v);
      if (u > v) swap(u, v);
      cnt[u]--;
      if (cnt[u] == 0) ans--;
    } else
      printf("%d\n", n - ans);
  }
  return 0;
}
