#include <bits/stdc++.h>
using namespace std;
pair<long long, pair<long long, long long> > temp, top;
vector<long long> graph[1234], wt[1234];
vector<long long> dis(1234, 0);
long long n, m;
long long id[1234][1234];
void dijkstra(long long src, long long des) {
  vector<bool> visited(1234, 0);
  priority_queue<pair<long long, pair<long long, long long> >,
                 vector<pair<long long, pair<long long, long long> > >,
                 greater<pair<long long, pair<long long, long long> > > >
      pq;
  pq.push(make_pair(0LL, make_pair(0LL, src)));
  while (!pq.empty()) {
    top = pq.top();
    pq.pop();
    if (visited[top.second.second] == 0) {
      visited[top.second.second] = 1;
      long long a1 = top.second.first;
      long long b1 = top.second.second;
      long long m = id[a1][b1];
      if (m >= 0) {
        dis[m]++;
      }
    }
    for (vector<long long>::iterator it1 = graph[top.second.second].begin(),
                                     it2 = wt[top.second.second].begin();
         it1 != graph[top.second.second].end(); it1++, it2++) {
      if (visited[*it1] == 0) {
        long long a1 = top.second.second;
        pq.push(make_pair(*it2 + top.first, make_pair(a1, *it1)));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < 1234; i++) {
    for (long long j = 0; j < 1234; j++) {
      id[i][j] = -1;
    }
  }
  long long counter = 1;
  while (m--) {
    long long a, b, c;
    cin >> a >> b >> c;
    id[a][b] = id[b][a] = counter++;
    graph[a].push_back(b);
    graph[b].push_back(a);
    wt[a].push_back(c);
    wt[b].push_back(c);
  }
  long long ans1 = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i != j) {
        dijkstra(i, j);
        ans1++;
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i < counter; i++) {
    if (dis[i] == 0) {
      ans = ans + 1;
    }
  }
  cout << ans << endl;
}
