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();
    }

    public static void WarshallFloyd(int[,] d, int v)
    {
	for (int k = 0; k < v; k++)
	    for (int i = 0; i < v; i++)
		for (int j = 0; j < v; j++)
		    d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
    }
}

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++)
		d[i,j] = M;

	List<Tuple<int,int,int>> e = new List<Tuple<int,int,int>>();
	for (int i = 0; i < m; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1], c = tmp[2];
	    e.Add(Tuple.Create(a-1, b-1, c));
	    d[a-1, b-1] = c;
	    d[b-1, a-1] = c;
	}

	WarshallFloyd(d, n);
	
	int ans = m;
	
	foreach (Tuple<int,int,int> t in e)
	{
	    int a = t.Item1, b = t.Item2, c = t.Item3;
	    for (int j = 0; j < n; j++)
	    {
		if (d[j,a] + c == d[j,b])
		{
		    ans--;
		    break;
		}
	    }
	}
	
	WriteLine(ans);
    }
}
