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 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;

            var a = new int[N];
            var b = new int[N];
            var c = new long[N];

            
            for(var i = 0; i < M; i++)
            {
                var input = cin.SplitRead();
                a[i] = input[0] - 1;
                b[i] = input[1] - 1;
                
                c[i] = input[2];

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

            Warshall_floyd(N, d);

            int ans = M;
            for(var i = 0; i < M; i++)
            {
                bool nouse = true;
                for(var j = 0; j < N; j++)
                {
                    if (d[j, a[i]] + c[i] == d[j, b[i]])
                    {
                        nouse = false;
                    }
                }
                ans -= nouse ? 0 : 1;
            }
            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++)
                    {
                        dist[i, j] = Min(dist[i, j], dist[i, k] + dist[k, j]);
                    }
                }
            }
        }

    }


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

}
