#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n, m, d[100][100], g[100][100];
int main()
{
    memset(d, 0x3f, sizeof(d));

    cin>>n>>m;
#define rep(i, n) for(int i=0;i<n;++i)
    rep(i, m) {
        int a, b, c; cin>>a>>b>>c;
        --a, --b;
        d[a][b]=d[b][a]=g[a][b]=g[b][a]=c;
    }
    rep(i, n) d[i][i]=0;
    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) res+=g[i][j]&&d[i][j]<g[i][j];
    cout<<res/2<<endl;
}
