#include <iostream>
#include <algorithm>
#define F(i) for(int i=0;i<100;i++)
using namespace std;
int main(void){
int n,m,g[100][100],h[100][100],a,b,c,ans=0,t;
cin>>n>>m;
F(i)F(j)g[i][j]=1e9;
for(t=0;t<m;t++){
cin>>a>>b>>c;
g[a-1][b-1]=c;
g[b-1][a-1]=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])ans++;
cout<<ans/2;
}
