#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a, b, c;
  vector<vector<int>> G(N, vector<int>(N, 1000000007));
  for (int i = 0; i < (M); i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = G[b][a] = c;
  }
  int ans = 0;
  set<pair<int, int>> s;
  for (int k = 0; k < (N); k++)
    for (int i = 0; i < (N); i++)
      for (int j = 0; j < (N); j++) {
        if (G[i][k] + G[k][j] < G[i][j]) {
          if (G[i][j] < 1e8) s.insert({min(i, j), max(i, j)});
          G[i][j] = G[i][k] + G[k][j];
        }
      }
  ans = (int)s.size();
  cout << ans << endl;
  return 0;
}
