#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,m;
    cin>>n>>m;
    int mat[n][n];
    bool check[n][n]={};
    int lim=10000000;
    rep(i,n)rep(j,n)mat[i][j]=lim;
    int next[n][n];
    rep(i,n)rep(j,n)next[i][j]=-1;
    rep(i,m){
        int ta,tb,tc;
        cin>>ta>>tb>>tc;
        ta--;
        tb--;
        mat[ta][tb]=tc;
        mat[tb][ta]=tc;
        next[ta][tb]=tb;
        next[tb][ta]=ta;
    }
    rep(k,n)rep(i,n)rep(j,n){
        if(mat[i][j]>mat[i][k]+mat[k][j]){
            mat[i][j]=mat[i][k]+mat[k][j];
            mat[j][i]=mat[i][k]+mat[k][j];
            next[j][i]=k;
            next[i][j]=k;
        }
    }
    int res=m;
    rep(i,n)rep(j,n){
        int k = next[i][j];
        assert(k!=-1);
        if(!check[i][k]&&!check[k][i]){
            res--;
            check[i][k]=true;
            check[k][i]=true;
        }
    }
    cout << res << endl;
    return 0;
}
