#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x, l = n + 1, r = 0;
  for (string a, b; cin >> a >> a >> a >> b >> x;
       (a[0] == 'l') ? l = min(x, l) : r = max(x, r))
    ;
  cout << (l - r < 2 ? -1 : l - r - 1);
}
