#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int N, M;
  cin >> N >> M;

  vector<vector<int>> G(N, vector<int>(N, INF));
  vector<pair<int, int>> E(M);
  for( int i = 0; i < N; i++ ) G.at(i).at(i) = 0;
  for( int i = 0; i < M; i++ ){
    int A, B, C;
    cin >> A >> B >> C;
    A--; B--;
    G.at(A).at(B) = C;
    G.at(B).at(A) = C;
    E.at(i) = {A, B};
  }

  vector<bool> fg(M, true);
  for (int k = 0; k < N; k++){       // 経由する頂点
    for (int i = 0; i < N; i++) {    // 始点
      for (int j = 0; j < N; j++) {  // 終点
        if( G[i][j] > G[i][k] + G[k][j] ){
          for( int p = 0; p < M; p++ ){
            pair<int, int> p1 = {k, j};
            pair<int, int> p2 = {j, k};
            if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false;
            p1 = {i, k};
            p2 = {k, i};
            if( E.at(p) == p1 || E.at(p) == p2 ) fg.at(p) = false;
          }
        }
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  int ans = 0;
  for( int i = 0; i < M; i++ ){
    if( fg.at(i) ) ans++;
  }
  cout << ans << endl;

 }
