#include <iostream>
#include <vector>
using namespace std;
const int INF = (1e9);
int main(){
  int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N, vector<int>(N,INF));
  vector<int> A(M), B(M), C(M);
  for(int i = 0; i < M; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    --a;--b;
    G[a][b] = c;
    G[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for(int k = 0; k < N; ++k){
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < M; ++i){
    if(G[A[i]][B[i]] != C[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}
