#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
const int MAX_V=110;
int d[MAX_V][MAX_V];
int V;
void warshall_floyd(){
  for(int k=1;k<=V;k++)
    for(int i=1;i<=V;i++)
      for(int j=1;j<=V;j++)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

int main(){
  int m;
  cin>>V>>m;
  int dp[V+1][V+1]={};
  for(int j=0;j<m;j++){
    int a,b,c;
    cin>>a>>b>>c;
    d[a][b]=c;
    d[b][a]=c;
    dp[a][b]=c;
    dp[b][a]=c;
  }
  int ans=m;
  warshall_floyd();
  for(int i=1;i<=V;i++){
    for(int j=i;j<=V;j++){
      //cout<<d[i][j]<<" ";
      if(dp[i][j]==d[i][j]&&dp[i][j]){
	//cout<<dp[i][j]<<endl;
	ans--;
      }
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}
