I=16843009;g[101][101];a,b,c;k;*d;x;main(n){for(scanf("%d%*d",&n);a++<n;)for(b=0;b++<n;)g[a][b]=a-b?I:0;for(;~scanf("%d%d%d",&a,&b,&c);)g[a][b]=g[b][a]=c;for(;k++<n;)for(a=0;a++<n;)for(b=0;b++<n;g[a][k]+g[k][b]<*d&&*d-I?*d=I,x++:0)d=g[a]+b;printf("%d",x/2);}