#include <bits/stdc++.h>
using namespace std;
int main() {
  int minn = 0, maxx, n, m, x;
  string s;
  cin >> n >> m;
  maxx = n + 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) cin >> s;
    if (s == "right") {
      cin >> s;
      cin >> x;
      minn = max(minn, x);
    } else {
      cin >> s;
      cin >> x;
      maxx = min(maxx, x);
    }
  }
  if (maxx <= minn || (maxx - minn - 1) == 0)
    cout << -1;
  else
    cout << maxx - minn - 1;
  return 0;
}
