int U[MAXN * 2], Enemy[MAXN * 2], n, m; int count[MAXN * 2], cnt;
inlineintgetint(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -1; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
inlinevoidputint(int x){ if (x < 0) { x = -x; } if (x >= 10) { putint(x / 10); } putchar(x % 10 + '0'); }
voidUnion(int x, int y){ x = Find(x), y = Find(y); if (x == y) return; U[x] = y; return; }
intmain(int argc, char *const argv[]){ freopen("P1892.in", "r", stdin); cin >> n >> m; for (int i = 0; i <= n * 2; ++i) U[i] = i; for (int i = 1; i <= m; ++i) { char c; int x, y; cin >> c >> x >> y; switch(c) { case'F': { Union(x, y); break; } case'E': { if (Enemy[x] == 0) Enemy[x] = Find(y); else Union(y, Enemy[x]); if (Enemy[y] == 0) Enemy[y] = Find(x); else Union(x, Enemy[y]); } } } for (int i = 1; i <= n; ++i) ++count[Find(i)]; for (int i = 1; i <= n; ++i) if (count[i]) ++cnt; printf("%d\n", cnt); return0; }