#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
const int MAX=101;
int n,m;
int M[MAX][MAX];
int L[MAX][MAX];


signed main(){
  cin>>n>>m;
  REP(i,n)REP(j,n){
    M[i][j]=(i==j?0:INF);
    L[i][j]=(i==j?0:INF);
  }
  REP(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    M[a][b]=c;
    M[b][a]=c;
    L[a][b]=c;
    L[b][a]=c;
  }
  REP(k,n)REP(i,n)REP(j,n)M[i][j]=min(M[i][j],M[i][k]+M[k][j]);

  int ans=0;
  REP(i,n)REP(j,n){
    if(L[i][j]!=INF&&(L[i][j]>M[i][j]))ans++;
  }
  cout<<ans/2<<endl;
  return 0;
}
