#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int n, m, a[1005], b[1005], c[1005], dis[105][105], ans;

int main(){
    scanf("%d%d", &n, &m);
    rep(i,n) rep(j,n) dis[i][j] = i == j ? 0 : 1e8;
    rep(i,m){
        scanf("%d%d%d", a+i, b+i, c+i);a[i]--;b[i]--;
        dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
    }
    rep(i,n) rep(j,n) rep(k,n) dis[j][k] = min(dis[j][k], dis[j][i] + dis[i][k]);
    rep(i,m) if(dis[a[i]][b[i]] < c[i]) ans++;
    printf("%d\n", ans);
}