#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

ll ans=0;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  int a[100]={0},b[100]={0},c[100]={0};
  int dist[1000][1000]=MAX;
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j){
        dist[i][j]=0;
      }else {
        dist[i][j]=MAX;
      }
    }
  }
  for(int i=0;i<M;i++){
    dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
    dist[b[i]][a[i]]=min(dist[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){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  int ans=M;
  for(int i = 0; i < M; ++i){
    bool shortest=false;
    for(int j = 0; j < N; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
    if(shortest==true){
    ans=ans-1;
    }
  }
  cout << ans << endl;
  return 0;
}