#include<iostream>
#include<vector>

using namespace std;

const int INF=100000008;

typedef vector<vector<int> > Matrix;
Matrix graph;


int main()
{
	int n,m;
	cin >> n >> m;

	graph=Matrix(n,vector<int>(n,INF));

	for(int i=0;i<n;i++)
		graph[i][i]=0;
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin >> a >> b >> c;
		graph[a-1][b-1]=c;
		graph[b-1][a-1]=c;
	}

	Matrix constGraph=graph;

	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
	
	int count=0;

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(graph[i][j]<constGraph[i][j] and constGraph[i][j]!=INF)
			{
				count++;
			}
	cout << count/2 << endl;
}


