#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(T a, int n) {
  for (int i = 0; i < n; ++i) cout << a[i] << ' ';
  cout << endl;
}
template <class T>
void show(T a, int r, int l) {
  for (int i = 0; i < r; ++i) show(a[i], l);
  cout << endl;
}
const int N = 1024;
const int M = 5000;
const int oo = 10000 * 10000 * 10;
int n, m;
int main() {
  int i, j, cas = 0;
  char s[100];
  char ts[100];
  scanf("%d %d", &n, &m);
  int lf = 0;
  int ri = n + 1;
  for (i = 0; i < m; ++i) {
    int d;
    scanf("%s", ts);
    scanf("%s", ts);
    scanf("%s", s);
    scanf("%s", ts);
    scanf("%d", &d);
    if (s[0] == 'l') {
      ri = (ri < d ? ri : d);
    } else
      lf = (lf > d ? lf : d);
  }
  int v = ri - lf - 1;
  if (v > 0)
    printf("%d\n", v);
  else
    printf("%d\n", -1);
  return 0;
}
