#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int M;
vector<int> a,b,c;

struct edge{
  int to;
  i64 cost;
};


vector<vector<i64>> dist;

int main(){
  cin >> N >> M;
  a.resize(M);
  c.resize(M);
  b.resize(M);
  dist.resize(N,vector<i64>(N,1e18));

  rep(i,0,M - 1){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }

  rep(k,0,N - 1) rep(i,0,N - 1) rep(j,0,N - 1)
    dist[i][j] = min(dist[i][j] , dist[i][k] + dist[k][j]);
  int ans = 0;
  rep(i,0,M - 1){
    if(dist[a[i]][b[i]] < c[i]){
      ans++;
    }
  }

  cout << ans << endl;
}
