#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M),B(M),C(M);
    int dist[N][N];
    rep(i,0,N)rep(j,0,N)dist[i][j] = INF;
    rep(i,0,N)dist[i][i] = 0;
    rep(i,0,M){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;B[i]--;
        dist[A[i]][B[i]] = dist[B[i]][A[i]] = C[i];
    }
    rep(i,0,N)rep(j,0,N)rep(k,0,N){
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
    }
    int cnt = 0;
    rep(i,0,M){
        if(dist[A[i]][B[i]] != C[i])cnt++;
    }
    cout << cnt << endl;

}