
#include <bits/stdc++.h>
#define For(i,n) for(int i=0; i<n; i++)
#define M0D 1000000007
using namespace std;

int main(){

  const int inf=100000000;
  int N,M;
  cin >> N >> M;
  int ans=M;

  int a[1000],b[1000],c[1000], dist[100][100];

  For(i,M){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
  }

  For(i,N) For(j,N){
    if(i==j) dist[i][j]=0;
    else dist[i][j]=inf;
  }

  For(i,M){
    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(k,N) For(i,N) For(j,N) dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

  For(i,M){
    bool shortest=false;
    For(j,N) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
    if(shortest) ans--;
  }
  cout << ans << endl;

  return 0;
}