#include <bits/stdc++.h>
char str[4][30] = {
    "right",
    "left",
};
int main() {
  char a[40];
  char b[40];
  char c[40];
  char d[40];
  int x;
  int n, m;
  scanf("%d%d", &n, &m);
  int left = 0;
  int right = n + 1;
  for (int i = 0; i < m; i++) {
    scanf("%s%s%s%s%d", a, b, c, d, &x);
    if (strcmp(c, str[0]))
      right = right > x ? x : right;
    else
      left = left < x ? x : left;
  }
  int t = right - left - 1;
  if (t <= 0) t = -1;
  printf("%d", t);
  scanf("%d");
}
