#include <bits/stdc++.h>
using namespace std;
int n, m;
bool tar[1003];
char s[10];
int main() {
  while (~scanf("%d %d", &n, &m)) {
    memset(tar, true, sizeof tar);
    int i = 0;
    while (i < m) {
      scanf("%s", s);
      scanf("%s", s);
      scanf("%s", s);
      if (s[0] == 'r') {
        scanf("%s", s);
        int a;
        scanf("%d", &a);
        for (; a > 0; a--) tar[a] = false;
      } else {
        scanf("%s", s);
        int a;
        scanf("%d", &a);
        for (; a <= n; a++) tar[a] = false;
      }
      i++;
    }
    int num = 0;
    for (int i = 1; i <= n; i++)
      if (tar[i]) num++;
    if (num == 0)
      printf("-1\n");
    else
      printf("%d\n", num);
  }
  return 0;
}
