#include <bits/stdc++.h>
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using namespace std;
class Solve {
 public:
  void input() {}
  void solve() {
    input();
    int N, M;
    cin >> N >> M;
    struct edge {
      int from, to;
      long long int w;
    };
    vector<long long int> ww(N);
    for (int i = int(0); i < int(N); i++) ww[i];
    long long int sum = accumulate(begin(ww), end(ww), 0ll);
    vector<edge> edges;
    for (int i = 0; i < M; ++i) {
      int x, y;
      long long int w;
      cin >> x >> y >> w;
      edge e({x, y, w});
      edges.push_back(e);
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
      if (edges[i].w > sum) ans++;
    }
    cout << ans << endl;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solve().solve();
  return 0;
}
