#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, m, l, r, ans;
  cin >> n >> m;
  l = 0, r = n + 1, ans = 0;
  char huiche, dir;
  scanf("%c", &huiche);
  for (int i = 0; i < m; i++) {
    getline(cin, s);
    int len = s.length() - 1, num = 0, tlen;
    dir = s[7], tlen = len;
    while (s[tlen] != ' ') tlen--;
    for (int j = 1; j + tlen <= s.length() - 1; tlen++)
      num = num * 10 + s[tlen + j] - '0';
    if (dir == 'l') {
      r = min(r, num);
      if (num < l || num == 1) ans = -1;
    } else if (dir == 'r') {
      l = max(l, num);
      if (num > r || num == n) ans = -1;
    }
    if (r < l || ans == -1) break;
  }
  if (ans == -1 || r - l == 1)
    cout << "-1";
  else {
    ans = r - l - 1;
    cout << ans;
  }
  return 0;
}
