#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int oo=1e9;
const int mx=123;
int g[mx][mx];
vector<tuple<int,int,int> >edges;
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)g[i][j]=oo;
  for(int i=0;i<n;i++)g[i][i]=0;
  while(m--){
    int u,v,c;
    scanf("%d %d %d",&u,&v,&c);
    --u,--v;
    edges.push_back(make_tuple(u,v,c));
    g[u][v]=g[v][u]=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]);            
  sort(edges.begin(),edges.end());
  int ans=0;
  for(auto e:edges){
    int u,v,c;
    tie(u,v,c)=e;
    if(g[u][v]<c)ans++;
  }
  printf("%d\n",ans);
  return 0;
}
