#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  int a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
  }
  cout << M - N + 1 << "\n";
}
