#include <bits/stdc++.h>
using namespace std;
int check[1000 + 10];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int h;
    char inp[10];
    char temp[10];
    cin >> inp >> inp >> inp >> temp >> h;
    int isleft = 0;
    cerr << inp << endl;
    if (inp[0] == 'l' && inp[1] == 'e' && inp[2] == 'f' && inp[3] == 't')
      isleft = 1;
    if (isleft)
      for (int k = h; k <= n; k++) check[k] = 1;
    else
      for (int k = h; k > 0; k--) check[k] = 1;
  }
  int cc = 0;
  for (int i = 1; i <= n; i++)
    if (!check[i]) cc++;
  if (cc == 0)
    cout << -1 << endl;
  else
    cout << cc << endl;
}
