#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  string hi[m];
  int ha[m];
  for (i = 0; i < m; i++) {
    string b;
    cin >> b >> b >> hi[i] >> b;
    scanf("%d", &ha[i]);
  }
  int box[n + 1];
  for (i = 0; i < n + 1; i++) box[i + 1] = 0;
  for (i = 0; i < m; i++) {
    if (hi[i] == "left")
      box[ha[i]] = 1;
    else if (hi[i] == "right")
      box[ha[i]] = -1;
  }
  int minl = n + 1, maxr = 0;
  for (i = 0; i < n + 1; i++)
    if (box[i] == 1 && minl == n + 1)
      minl = i;
    else if (box[i] == -1)
      maxr = i;
  if (minl <= maxr + 1)
    cout << -1;
  else
    cout << minl - maxr - 1;
  return 0;
}
