#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int l = 1, r = n + 1;
  for (int i = 0; i < m; i++) {
    char c[5][10];
    int t;
    scanf("%s%s%s%s%d", c[0], c[1], c[2], c[3], &t);
    if (c[2][0] == 'l') {
      if (t < r) r = t;
    } else if (t + 1 > l)
      l = t + 1;
  }
  int res = r - l;
  if (res <= 0) res = -1;
  printf("%d\n", res);
  return 0;
}
