#include<iostream>
#include<algorithm>
#define F(i) for(int i=0;i<101;i++)
using namespace std;
int main(){
int n,m,g[101][101],h[101][101],a,b,c,x=0,t;
cin>>n>>m;F(i)F(j)g[i][j]=1e9;
while(m--){cin>>a>>b>>c;g[a][b]=g[b][a]=c;}
F(i)F(j)h[i][j]=g[i][j];
F(k)F(i)F(j)g[i][j]=min(g[i][k]+g[k][j],g[i][j]);
F(i)F(j)if(h[i][j]!=1e9&&g[i][j]<h[i][j])x++;
cout<<x/2;
}