#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1007;
bitset<MAXN> edg;
bitset<MAXN> edgg;
vector<pair<pair<int, int>, int> > adjList[MAXN];
int dist[MAXN], ans;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  int N, E, S;
  cin >> N >> E;
  int u, v, w;
  for (int i = 0; i < E; i++) {
    cin >> u >> v >> w;
    adjList[u].push_back(pair<pair<int, int>, int>(pair<int, int>(w, i), v));
  }
  for (int S = 1; S <= N; S++) {
    memset(dist, -1, sizeof(dist));
    dist[S] = 0;
    pq.push(pair<int, int>(0, S));
    while (!pq.empty()) {
      pair<int, int> front = pq.top();
      pq.pop();
      int u = front.second;
      int d = front.first;
      if (d > dist[u]) continue;
      for (int i = 0; i < adjList[u].size(); i++) {
        int vv = adjList[u][i].second;
        int vd = adjList[u][i].first.first;
        if (dist[vv] == -1 || dist[vv] > dist[u] + vd) {
          dist[vv] = dist[u] + vd, pq.push(pair<int, int>(dist[vv], vv));
          edg[adjList[u][i].first.second] = 1;
          edg[adjList[u][vv].first.second] = 0;
        }
      }
    }
    for (int i = 1; i <= N; i++) {
      if (edg[i] == 1) edgg[i] = 1;
      edg[i] = 0;
    }
  }
  for (int i = 1; i <= N; i++)
    if (edgg[i] == 0) ans++;
  cout << ans << endl;
  return 0;
}
