#include <bits/stdc++.h>
#include <assert.h>

using namespace std;

struct Edge
{
	int to, cost;
	bool use = false;
};

int n;
vector<Edge> edge[100];

int dijkstra(int from, int to)
{
	vector<int> cost(n, 1e9);
	queue<int> que;
	cost[from] = 0;
	que.push(from);
	while (que.size())
	{
		int now = que.front();
		que.pop();
		for (int i = 0; i < edge[now].size(); i++)
			if (cost[now] + edge[now][i].cost < cost[edge[now][i].to])
			{
				edge[now][i].use = true;
				cost[edge[now][i].to] = cost[now] + edge[now][i].cost;
				que.push(edge[now][i].to);
			}
	}
	return 0;
}

int main()
{
	int m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		edge[a].push_back({b, c});
		edge[b].push_back({a, c});
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			dijkstra(i, j);
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < edge[i].size(); j++)
			if (!edge[i][j].use)
			{
				ans++;
			}
	cout << ans << endl;

	return 0;
}