#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(int argc, const char* argv[]) {
  ll n, m;
  cin >> n >> m;
  ll fs[n];
  ll ans = n;
  for (ll i = 0; i < n; i++) {
    fs[i] = 0;
  }
  for (ll i = 0; i < m; i++) {
    ll u, v;
    cin >> u >> v;
    if (u < v) {
      if (fs[u - 1] == 0) {
        ans--;
      }
      fs[u - 1]++;
    } else {
      if (fs[v - 1] == 0) {
        ans--;
      }
      fs[v - 1]++;
      ;
    }
  }
  ll q;
  cin >> q;
  for (ll i = 0; i < q; i++) {
    ll first;
    cin >> first;
    if (first == 1) {
      ll u, v;
      cin >> u >> v;
      if (u < v) {
        if (fs[u - 1] == 0) {
          ans--;
        }
        fs[u - 1]++;
      } else {
        if (fs[v - 1] == 0) {
          ans--;
        }
        fs[v - 1]++;
        ;
      }
      continue;
    }
    if (first == 2) {
      ll u, v;
      cin >> u >> v;
      if (u < v) {
        fs[u - 1]--;
        if (fs[u - 1] == 0) {
          ans++;
        }
      } else {
        fs[v - 1]--;
        if (fs[u - 1] == 0) {
          ans++;
        }
      }
      continue;
    }
    if (first == 3) {
      cout << ans << endl;
    }
  }
  return 0;
}
