#include <bits/stdc++.h>
using namespace std;
int n, m;
char to[10];
char the[10];
char d[10];
char of[10];
int num;
bool can[2000];
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = 1; i <= n; i++) can[i] = 1;
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%s %s %s %s %d\n", to, the, d, of, &k);
    if (d[0] == 'l') {
      for (int i = k; i <= n; i++) can[i] = false;
    } else {
      for (int i = 1; i <= k; i++) can[i] = false;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += can[i];
  if (ans)
    printf("%d\n", ans);
  else
    printf("-1\n");
  return 0;
}
