using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int M = 1000000;
	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];
	int[,] d = new int[n,n];

	for (int i = 0; i < n; i++)
	{
	    for (int j = 0; j < n; j++)
	    {
		if (i==j) d[i,j] = 0;
		else      d[i,j] = M;
	    }
	}

	for (int i = 0; i < m; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1], c = tmp[2];
	    d[a-1, b-1] = c;
	    d[b-1, a-1] = c;
	}

	bool[,] deleted = new bool[n,n];

	int ans = 0;

	for (int k = 0; k < n; k++)
	{
	    for (int i = 0; i < n; i++)
	    {
		for (int j = 0; j < n; j++)
		{
		    if (d[i,j] != M && d[i, j] > d[i, k] + d[k, j])
		    {
			if (deleted[j,i]){ ans++; }
			d[i, j] = d[i, k] + d[k, j];
			deleted[i,j] = true;
		    }
		}
	    }
	}

	WriteLine(ans);
    }
}
