#include<bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 101
int d[MAX_V][MAX_V];
int V;

int main(){
    scanf("%d",&V);
    int v = V+1,e,a[1000],b[1000],c[1000],ans=0;
    FOR(i,1,v) FOR(j,1,v) d[i][j] = INF;
    REP(i,v) d[i][i] = 0;
    scanf("%d",&e);
    REP(i,e) scanf("%d%d%d",a+i,b+i,c+i);
    REP(i,e) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];

    FOR(k,1,v) FOR(i,1,v) FOR(j,1,v) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);

    bool used;
    REP(i,e){
        used = true;
        FOR(s,1,v) if(d[s][a[i]] + c[i] == d[s][b[i]]) used = false;
        if(used) ++ans;
    }

    printf("%d\n",ans);
    return 0;
}
