#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int A[100][100];
vector<vector<pair<int,int> > > G(100);
const int INF=INT_MAX/2;

int main(){
  rep(i,100) rep(j,100){
    if(i==j) A[i][j]=0;
    else A[i][j]=INF;
  }
  int N,M; cin>>N>>M;
  rep(i,M){
    int a,b,c; cin>>a>>b>>c; a--,b--;
    A[a][b]=A[b][a]=c;
    G[a].push_back(make_pair(b,c));
    G[b].push_back(make_pair(a,c));
  }
  rep(k,N) rep(i,N) rep(j,N) A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
  int ans=0;
  rep(i,N) rep(j,G[i].size()){
    int b=G[i][j].first, c=G[i][j].second;
    if(A[i][b]<c) ans++;
  }
  cout<<ans/2<<endl;
  return 0;
}
