#include <bits/stdc++.h>
using namespace std;
const int mm = 1e6;
long long int d[mm];
int main() {
  int n, m, i, r, l, k;
  string s, sss;
  cin >> n >> m;
  r = 0;
  l = n + 1;
  getchar();
  for (i = 0; i < m; i++) {
    cin >> sss;
    cin >> sss;
    cin >> s;
    cin >> sss;
    cin >> k;
    if (s[0] == 'r')
      r = max(r, k);
    else
      l = min(l, k);
  }
  if ((l == 1 || r == n) || (l <= (r + 1))) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", l - r - 1);
}
