#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));
    dp[a][b] = c;
    dp[b][a] = c;
  }
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < n + 1; ++j) {
      for (int k = 1; k < n + 1; ++k) {
        dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
      }
    }
  }
  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++;
    }
  }
  cout << m - total << endl;
  return 0;
}
