using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static int[,] nx;
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var p = cin.SplitRead();
            int N = p[0];
            int M = p[1];
            var d = new long[N, N];
            for (var i = 0; i < N; i++) for (var j = 0; j < N; j++) d[i, j] = i == j ? 0 : SINF;

            nx = new int[N, N];
            for (var i = 0; i < N; i++) for (var j = 0; j < N; j++) nx[i, j] = j;


            var ed = new Dictionary<Tuple<int, int>, int>();
            for(var i = 0; i < M; i++)
            {
                var input = cin.SplitRead();
                int a = input[0] - 1;
                int b = input[1] - 1;
                long c = input[2];

                ed.Add(new Tuple<int, int>(Max(a, b), Min(a, b)), 0);
                d[a, b] = c;
                d[b, a] = c;
            }

            Warshall_floyd(N, d);

            int ans = M;
            var h = new HashSet<Tuple<int, int>>();
            for(var i = 0; i < N; i++)
            {
                for(var j = 0; j < N; j++)
                {
                    if (i == j) { continue; }
                    h.Add(new Tuple<int, int>(Max(i, nx[i, j]), Min(i, nx[i, j])));
                }
                
            }

            foreach(var e in h)
            {
                //Console.WriteLine(e);
                ans -= ed.ContainsKey(e) ? 1 : 0;
            }
            
            Console.WriteLine(ans);
            

        }

        static public void Warshall_floyd(int n, long[,] dist)
        {
            for (var k = 0; k < n; k++)
            {
                for (var i = 0; i < n; i++)
                {
                    for (var j = 0; j < n; j++)
                    {
                        if (dist[i, j] > dist[i, k] + dist[k, j]) 
                        {
                            dist[i, j] = dist[i, k] + dist[k, j];
                            nx[i, j] = k;
                        }
                    }
                }
            }
        }

    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}
