#define i(a,b) a=a<b?a:b
#define f(a) for(a=0;a++<n;)
d,a[101][101],b[101][101],u,v,c;main(n){scanf("%d%*d",&n);f(u)f(v)b[u][v]=1e8;for(;~scanf("%d%d%d",&u,&v,&c);a[u][v]=b[u][v]=c);f(c)f(u)f(v)i(b[u][v],b[u][c]+b[c][v]);f(u)f(v)d+=a[u][v]>b[u][v];printf("%d\n",d);}