#include <bits/stdc++.h>

using namespace std;

const int inf=1000000000;

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
 int n,m;
  cin >> n >> m;
 int a[m],b[m],c[m];
  rep(i,m){ cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  
  int dis[n][n];
  rep(i,n){
    rep(j,n){
     if(i==j) dis[i][j]=0;
     else dis[i][j]=inf;
    }
  }
 
  rep(i,m){
   dis[a[i]][b[i]]=min(dis[a[i]][b[i]],c[i]);
   dis[b[i]][a[i]]=dis[a[i]][b[i]];
  }
  
  rep(k,n){
   rep(i,n){
    rep(j,n){
     dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    }
   }
  }
  
  int res=m;
  rep(i,m){
   bool flag=false;
    rep(j,n){
     if(dis[j][a[i]]+c[i]==dis[j][b[i]]) flag=true;
    }
    if(flag) res--;
  }


  cout << res << endl;
}