using System;

namespace ABC051
{
    class Program
    {
        static void Main(string[] args)
        {

            int[,] dist = new int[100, 1000];

            string[] input;
            input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int[] a = new int[N];
            int[] b = new int[N];
            int[] c = new int[N];
            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                a[i] = int.Parse(input[0]) - 1;
                b[i] = int.Parse(input[1]) - 1;
                c[i] = int.Parse(input[2]);

                dist[a[i], b[i]] = c[i];
                dist[b[i], a[i]] = c[i];
            }

            // Warshall–Floyd Initialize
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    dist[i, j] = int.MaxValue;
                }
                dist[i, i] = 0;
            }

            // Warshall–Floyd
            for (int k = 0; k < N; k++)
            {
                for (int i = 0; i < N; i++)
                {
                    for (int j = 0; j < N; j++)
                    {
                        dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);
                    }
                }
            }

            int result = 0;
            for (int i = 0; i < N; i++)
            {
                if (c[i] > dist[a[i], b[i]]) result++;
            }
            Console.WriteLine(result);
        }
    }
}
