#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;


int main(){

  int n,m,a[1000],b[1000],c[1000],dist[100][100],ans =0;
  cin >> n>> m;
  
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
     
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j){
      dist[i][j] = 0;
      }
      else{
        dist[i][j] = 1e9;
      }
    }
  }
  
  
  for(int i=0;i<m;i++){
    
      dist[a[i]][b[i]] = min(dist[a[i]][b[i]],c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]],c[i]);
    
  }
  
 
  for (int k = 0; k < n; k++){       
    for (int i = 0; i < n; i++) {    
      for (int j = 0; j < n; j++) {  
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  
  for(int i=0;i<m;i++){
    bool ant = false;
    for(int j=0;j<n;j++){
    if(dist[j][a[i]] ==dist[a[i]][b[i]]-c[i]){
      ant = true;
    }
      if(ant){
        ans++;
      }
    }
  }
  
  cout << m-ans << endl;
}
  
  
  
  
  
  