#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a;
  cin >> n >> m;
  int l = 0, r = n + 1;
  string s, s1;
  for (int i = 0; i < m; i++) {
    cin >> s >> s >> s1 >> s >> a;
    if (s1[0] == 'r')
      l = max(l, a);
    else
      r = min(a, r);
  }
  int ans = r - l - 1;
  if (ans <= 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
