#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> edge(n + 1, vector<long long>(n + 1, INT_MAX));
  vector<vector<long long>> edgei;
  for (long long i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a][b] = c;
    edge[b][a] = c;
  }
  for (long long i = 0; i < (n); i++) {
    edge[i + 1][i + 1] = 0;
  }
  edgei = edge;
  for (long long k = 0; k < (n + 1); k++) {
    for (long long i = 0; i < (n + 1); i++) {
      for (long long j = 0; j < (n + 1); j++) {
        edgei[i][j] = min(edgei[i][j], edge[i][k] + edge[k][j]);
      }
    }
  }
  int ans = 0;
  for (long long i = 0; i < (n); i++) {
    for (long long j = 0; j < (n); j++) {
      if (i < j && edge[i][j] != INT_MAX) {
        if (edge[i + 1][j + 1] != edgei[i + 1][j + 1]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
