#include <iostream>
using namespace std;
int INF = 1<<29;
int main(void){
    int n,m,ans = 0;
    cin >> n >> m;
    int a[1100],b[1100],c[1100],d[110][110];
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++)d[i][j] = INF;
        d[i][i] = 0;
    }
    
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    
    for(int k = 0;k < n;k++)
    for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++) 
    if(d[i][j] > d[i][k]+d[k][j]) d[i][j] = d[i][k]+d[k][j];
    
    for(int i = 0;i < m;i++){
        if(c[i] > d[a[i]][b[i]]) ans++;
    }
    cout << ans << endl;
    return 0;
}
