#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N,M;cin>>N>>M;
    ll d[N][N];
    REP(i,N){
        REP(j,N)d[i][j]=INF;
        d[i][i]=0;
    }
    int a,b;ll c;
    REP(i,M){
        scanf("%d %d %d",&a ,&b ,&c);
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    ll d1[N][N];
    REP(i,N)REP(j,N)d1[i][j]=d[i][j];
    REP(k,N)REP(i,N)REP(j,N)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    int res=0;
    REP(i,N)REP(j,N){
        if(i<j && d1[i][j]!=INF && d[i][j]<d1[i][j])res++;
    }
    cout<<res<<endl;
    return 0;
}