#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int dp[101][101] = {};
  for (int i = 0; i < 101; ++i) {
    for (int j = 0; j < 101; ++j) {
      dp[i][j] = 1001;
    }
  }
  int a, b, c;
  int total = 0;
  struct pair<int, struct pair<int, int> > d[1001];
  for (int i = 0; i < m; ++i) {
    cin >> a >> b >> c;
    d[i] = struct pair<int, struct pair<int, int> >(
        c, struct pair<int, int>(a, b));
  }
  sort(d, d + m);
  for (int i = 0; i < m; ++i) {
    c = d[i].first;
    a = d[i].second.first;
    a = d[i].second.second;
    if (dp[a][b] >= c) {
      total++;
      dp[a][b] = c;
      dp[b][a] = c;
    }
    for (int i = 1; i < n + 1; ++i) {
      dp[a][i] = min(dp[a][i], dp[a][b] + dp[b][i]);
      dp[i][a] = dp[a][i];
      dp[b][i] = min(dp[b][i], dp[a][b] + dp[a][i]);
      dp[i][b] = dp[b][i];
    }
  }
  cout << m - total << endl;
  return 0;
}
