#include<iostream>
using namespace std;
int main(void){
2 const int inf = 100000000;
3
3
4 int n,m;
5 cin >> n >> m;
6
7 int a[1000],b[1000],c[1000],dist[100][100];
8
9 for(int i = 0; i < m; ++i){
10 cin >> a[i] >> b[i] >> c[i];
11 a[i]--,b[i]--;
12 }
13
14 for(int i = 0; i < n; ++i){
15 for(int j = 0; j < n; ++j){
16 if(i==j)
17 dist[i][j]=0;
18 else
19 dist[i][j]=inf;
20 }
21 }
22
23 for(int i = 0; i < m; ++i){
24 dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
25 dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
26 }
27
28 for(int k = 0; k < n; ++k){
29 for(int i = 0; i < n; ++i){
30 for(int j = 0; j < n; ++j){
31 dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
32 }
33 }
34 }
35
36 int ans=m;
37 for(int i = 0; i < m; ++i){
38 bool shortest=false;
39 for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
40 if(shortest==true){
41 ans=ans-1;
42 }
43 }
44
45 cout << ans << endl;
46 }