#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL INF = 1e18;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<LL>> G(N, vector<LL>(N, INF)), d(N, vector<LL>(N, INF)),
      use(N, vector<LL>(N, 1));
  for (int i = 0; i < N; i++) G[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    G[ai - 1][bi - 1] = ci;
    G[bi - 1][ai - 1] = ci;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (G[i][j] > G[i][k] + G[k][j]) use[i][j] = 0;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (G[i][j] < INF && !use[i][j]) ans++;
    }
  }
  cout << ans / 2 << endl;
}
