#include<bits/stdc++.h>
using namespace std;
int N, M;
int adj[101][101];
int dis[101][101];
int main()
{
    scanf("%d%d", &N, &M);
    for(int i=0; i<N; ++i)
        for(int j=0; j<i; ++j)
            adj[i][j] = dis[i][j] = adj[j][i] = dis[j][i] = 0x3f3f3f3f;
        
    for(int i=0; i<M; ++i)
    {
        int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b;
        dis[a][b] = dis[b][a] = adj[a][b] = adj[b][a] = c;
    }
    for(int k=0; k<N; ++k)
        for(int i=0; i<N; ++i)
            for(int j=0; j<N; ++j)
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
    int ans = 0;
    for(int i=0; i<N; ++i)
        for(int j=0; j<i; ++j)
            if(adj[i][j] != 0x3f3f3f3f && dis[i][j] != adj[i][j])
                ++ans;
    printf("%d\n", ans);
}