#include <bits/stdc++.h>
using namespace std;
int d[100][100];
int main() {
  vector<pair<int, pair<int, int> > > l;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    l.push_back(make_pair(c, make_pair(a, b)));
  }
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (n); j++)
      if (i != j) d[i][j] = 1e9;
  sort((l).begin(), (l).end());
  int cnt = 0;
  for (int i = 0; i < (l.size()); i++) {
    int c = l[i].first;
    int a = l[i].second.first;
    int b = l[i].second.second;
    if (d[a][b] < c) {
      cnt++;
    } else {
      d[a][b] = d[b][a] = c;
      for (int i = 0; i < (n); i++) {
        if (d[a][i] > d[a][b] + d[b][i]) {
          d[a][i] = d[i][a] = d[a][b] + d[b][i];
        }
        if (d[b][i] > d[b][a] + d[a][i]) {
          d[b][i] = d[i][b] = d[b][a] + d[a][i];
        }
      }
    }
  }
  cout << cnt << endl;
}
