int fa[maxn]; voidinit_fa(){ for (int i = 1; i <= n; ++i) fa[i] = i; }
intfind(int x){ return fa[x] == x ? x : fa[x] = find(fa[x]); }
inlinevoidmerge(int x, int y){ int fx = find(x), fy = find(y); if (fx == fy) return ; fa[fx] = fy; }
inlinevoidsolve_1(){ int x, y; scanf("%d%d", &x, &y); merge(x, y); }
inlinevoidsolve_2(){ int x, y; scanf("%d%d", &x, &y); if (!e[x]) e[x] = y; else merge(e[x], y); if (!e[y]) e[y] = x; else merge(e[y], x); }
intmain(){ cin >> n >> m; init_fa(); for (int i = 1; i <= m; ++i) { char ch[5]; scanf("%s", &ch); switch (ch[0]) { case'F' : solve_1(); break; case'E' : solve_2(); break; } } int ans = 0; for (int i = 1; i <= n; ++i) ans += find(i) == i; cout << ans << endl; return0; }