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