#include <bits/stdc++.h>
using namespace std;
int n, m, res;
int a[108], b[108], c[108];
int dist[108000];
vector<pair<int, int> > edge[108];
void dijkstra(int s) {
  for (int i = 0; i < n; i++) dist[i] = (1 << 29);
  dist[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(pair<int, int>(0, s));
  while (!pq.empty()) {
    pair<int, int> tmp = pq.top();
    pq.pop();
    int from = tmp.second;
    int d = tmp.first;
    if (dist[from] < d) continue;
    for (int i = 0; i < edge[from].size(); i++) {
      int to = edge[from][i].first;
      int c = edge[from][i].second;
      if (dist[from] + c < dist[to]) {
        dist[to] = dist[from] + c;
        pq.push(pair<int, int>(dist[to], to));
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    edge[a[i]].push_back(pair<int, int>(b[i], c[i]));
    edge[b[i]].push_back(pair<int, int>(a[i], c[i]));
  }
  for (int i = 0; i < m; i++) {
    dijkstra(a[i]);
    if (dist[b[i]] != c[i]) res++;
  }
  cout << res << endl;
  return 0;
}
