using System;
using System.Collections.Generic;
using System.Linq;
//using System.Numerics;
class Program
{     
    
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        int[][] distance =
            Enumerable.Range(0, n)
            .Select(x => new int[n])
            .ToArray();
        var node =
            Enumerable.Range(0, m)
            .Select(x => Console.ReadLine().Split()
                .Select(int.Parse).ToArray())
            .Select(x => new {a = x[0] - 1, b = x[1] - 1, dis = x[2]})
            .ToArray();
        foreach(var item in node)
        {
            distance[item.a][item.b] = item.dis;
            distance[item.b][item.a] = item.dis;
        }
        foreach(int count in Enumerable.Range(0, n))
            foreach(int i in Enumerable.Range(0, n))
                foreach(int j in Enumerable.Range(0, n))
                    foreach(int k in Enumerable.Range(0, n))
                    {
                        if(distance[j][k] != 0 && distance[i][j] != 0)
                            distance[i][k] = Math.Min(distance[i][k], distance[j][k] + distance[i][j]);
                    }
        int result = node.Count(x => distance[x.a][x.b] != x.dis);
        System.Console.WriteLine(result);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}
