#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <cassert>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define fill(a,v) memset(a,v,sizeof(a))
#define bitcount __buitin_popcount
#define gcd __gcd
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vi > vvi;
map<pii,int> visited;
map<pii,vector<pii> > adj;
void dfs(pii src)
{
visited[src] = 1;
for(int i = 0 ; i < adj[src].size() ; ++i)
if(!visited[adj[src][i]]) dfs(adj[src][i]);
}
int main()
{
long long n;
while(cin >> n)
{
if(n == -1) return 0;
int q;
cin >> q;
pii query[q];string parity[q];
adj.clear();
for(int i = 0 ; i < q ; ++i)
{
int x,y;string par;
cin >> x >> y >> par;
query[i].fi = x;query[i].se = y; parity[i] = par;
}
int cnt = 0;
for(int i = 0 ; i < q ; ++i)
{
int x = query[i].fi;
int y = query[i].se;
pii t = mp(x-1,0),t1 = mp(x-1,1),d = mp(y,0),d1 = mp(y,1);
if(parity[i] == "even")
{
adj[t1].pb(d1);
adj[d1].pb(t1);
adj[d].pb(t);
adj[t].pb(d);
}
else if(parity[i] == "odd")
{
adj[t].pb(d1);
adj[d1].pb(t);
adj[t1].pb(d);
adj[d].pb(t1);
}
visited.clear();
dfs(mp(x-1,1));
if(visited[mp(x-1,1)] == 1 && visited[mp(x-1,0)] == 1) goto p;
visited.clear();
dfs(mp(y,0));
if(visited[mp(y,0)] == 1 && visited[mp(y,1)] == 1) goto p;
cnt++;
}
p : cout << cnt << endl;
}
}
I2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3RpbWU+CiNpbmNsdWRlIDxkZXF1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jXVtpXV0pICBkZnMoYWRqW3NyY11baV0pOwp9CmludCBtYWluKCkKewogICAKCiAgICBsb25nIGxvbmcgbjsKICAgIHdoaWxlKGNpbiA+PiBuKQogICAgewogICAgICAgIGlmKG4gPT0gLTEpIHJldHVybiAwOwoKICAgICAgICBpbnQgcTsKICAgICAgICBjaW4gPj4gcTsKICAgICAgICBwaWkgcXVlcnlbcV07c3RyaW5nIHBhcml0eVtxXTsKICAgICAgICBhZGouY2xlYXIoKTsKICAgICAgICBmb3IoaW50IGkgPSAwIDsgaSA8IHEgOyArK2kpCiAgICAgICAgewogICAgICAgICAgICBpbnQgeCx5O3N0cmluZyBwYXI7CiAgICAgICAgICAgIGNpbiA+PiB4ID4+IHkgPj4gcGFyOwogICAgICAgICAgICBxdWVyeVtpXS5maSA9IHg7cXVlcnlbaV0uc2UgPSB5OyBwYXJpdHlbaV0gPSBwYXI7CiAgICAgICAgfQoKICAgICAgICBpbnQgY250ID0gMDsKICAgICAgICBmb3IoaW50IGkgPSAwIDsgaSA8IHEgOyArK2kpCiAgICAgICAgewogICAgICAgICAgICBpbnQgeCA9IHF1ZXJ5W2ldLmZpOwogICAgICAgICAgICBpbnQgeSA9IHF1ZXJ5W2ldLnNlOwogICAgICAgICAgICBwaWkgdCA9IG1wKHgtMSwwKSx0MSA9IG1wKHgtMSwxKSxkID0gbXAoeSwwKSxkMSA9IG1wKHksMSk7IAogICAgIAogICAgICAgICAgICBpZihwYXJpdHlbaV0gPT0gImV2ZW4iKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIGFkalt0MV0ucGIoZDEpOwogICAgICAgICAgICAgICAgYWRqW2QxXS5wYih0MSk7CiAgICAgICAgICAgICAgICBhZGpbZF0ucGIodCk7CiAgICAgICAgICAgICAgICBhZGpbdF0ucGIoZCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZihwYXJpdHlbaV0gPT0gIm9kZCIpCiAgICAgICAgICAgIHsgICAKICAgICAgICAgICAgICAgIGFkalt0XS5wYihkMSk7CiAgICAgICAgICAgICAgICBhZGpbZDFdLnBiKHQpOwogICAgICAgICAgICAgICAgYWRqW3QxXS5wYihkKTsKICAgICAgICAgICAgICAgIGFkaltkXS5wYih0MSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmlzaXRlZC5jbGVhcigpOwogICAgICAgICAgICBkZnMobXAoeC0xLDEpKTsKICAgICAgICAgICAgaWYodmlzaXRlZFttcCh4LTEsMSldID09IDEgJiYgdmlzaXRlZFttcCh4LTEsMCldID09IDEpIGdvdG8gcDsKCiAgICAgICAgICAgIHZpc2l0ZWQuY2xlYXIoKTsKICAgICAgICAgICAgZGZzKG1wKHksMCkpOwogICAgICAgICAgICBpZih2aXNpdGVkW21wKHksMCldID09IDEgJiYgdmlzaXRlZFttcCh5LDEpXSA9PSAxKSBnb3RvIHA7CiAgICAgICAgICAgIAogICAgICAgICAgICBjbnQrKzsKICAgICAgICB9CgoKICAgICAgICBwIDogY291dCA8PCBjbnQgPDwgZW5kbDsKICAgIH0KCn0KCgoK