#include <bits/stdc++.h>
using namespace std;
long long n, m, z, u, l, s, h, k, y, x, t, a[985486], b[987654], d[987654],
    e[685868], c[2001][2001];
long long i, j;
map<long long, long long> f;
string p[987654], q[987654], r[987654], w[987654];
int main() {
  cin >> n;
  cin >> m;
  l = 0;
  k = n + 1;
  for (i = 0; i < m; i++) {
    cin >> p[i];
    cin >> q[i];
    cin >> r[i];
    cin >> w[i];
    cin >> a[i];
    if (r[i] == "right") {
      l = max(l, a[i]);
    } else {
      k = min(k, a[i]);
    }
  }
  if (k - l <= 1) {
    cout << -1;
    return 0;
  }
  cout << k - l - 1;
}
