#include <iostream>
#include<vector>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<vector<int>> dp(n,vector<int>(n,1e9));
vector<int[3]> g(m);
for(auto &a:g){
for(auto&b:a)cin>>b,b--;
dp[a[0]][a[1]]=dp[a[1]][a[0]]=a[2];
}
for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(dp[i][k]+dp[k][j]<=dp[i][j])dp[i][j]=dp[i][k]+dp[k][j];
int ans=0;
for(auto &a:g)if(dp[a[0]][a[1]]!=a[2])ans++;
cout<<ans<<endl;
}