#include <bits/stdc++.h>
inline int rit() {
  int f = 0, key = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') key = -1;
    ;
  } while (ch < '0' || ch > '9');
  do {
    f = f * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * key;
}
using namespace std;
int main(void) {
  int n, m;
  n = rit(), m = rit();
  if (m - n + 1 < 0)
    printf("0\n");
  else
    printf("%d\n", m - n + 1);
  for (int i = 0; i < int(m); i++) n = rit(), n = rit(), n = rit();
}
