#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> path(110,vector<int>(110,-1));
int shorter(int s,int e){
  if(path[s][e] == -1) return 0;
  int MIN = path[s][e];
  for(int i = 0;i < 110;i++){
    if(path[s][i]==-1)break;
    else{
      MIN = min(MIN,shorter(i,e));
    }
  }
  if(MIN < path[s][e])return 1;
  else 0;
}  
int main(){
  int n,m;
  cin >> n >> m;
  int ans = 0;
  for(int i = 0;i < m;i++){
    int a,b,c;
    cin >> a >> b >> c;
    path[a][b] = c;
    path[b][a] = c;
  }
  for(int i = 1;i <= n;i++){
    path[i][i] = 0;
  }    
  for(int i = 1;i <= n;i++){
    for(int j = 1 < i;j++){
      ans += shorter(i,j);
    }
  }
  cout << ans << endl;
}
      