using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    partial class Program
    {
        static long mod = 1000000007;
        static void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
            Console.ReadKey();
        }

        //ここから
        static void Solve()
        {
            int N; int M;
            Multi(out N, out M);
            var abc = GetIntJaggedArray(M);
            var path = Enumerable.Range(0, N).ToDictionary(s => s, s => new List<Tuple<int, int>>());
            for (int i = 0; i < M; i++)
            {
                var a = abc[i][0] - 1;
                var b = abc[i][1] - 1;
                var c = abc[i][2];
                path[a].Add(new Tuple<int, int>(b, c));
                path[b].Add(new Tuple<int, int>(a, c));
            }

            var set = new HashSet<Tuple<int, int>>();

            var haschecked = CreateJaggedArray(N, N, false);
            for (int i = 0; i < N; i++)
            {
                haschecked[i][i] = true;
            }

            PriorityQueue<Pair> pq;
            int[] len; ;
            int[] from;
            for (int s = 0; s < N; s++)
            {
                for (int g = 0; g < N; g++)
                {
                    if (haschecked[s][g]) continue;

                    pq = new PriorityQueue<Pair>();
                    len = Enumerable.Repeat(-1, N).ToArray();
                    from = Enumerable.Repeat(-1, N).ToArray();

                    pq.Push(new Pair(s, 0));
                    len[s] = 0;
                    while (pq.Count > 0)
                    {
                        var now = pq.Peek();
                        pq.Pop();
                        foreach (var next in path[now.Node])
                        {
                            var cost = now.Cost + next.Item2;
                            if (len[next.Item1] == -1 || len[next.Item1] > cost)
                            {
                                len[next.Item1] = cost;
                                from[next.Item1] = now.Node;
                                pq.Push(new Pair(next.Item1, cost));
                            }
                        }
                    }
                    var tmp = new HashSet<int>();
                    while (from[g] != -1)
                    {
                        tmp.Add(g);
                        set.Add(new Tuple<int, int>(Math.Min(g, from[g]), Math.Max(g, from[g])));
                        g = from[g];
                    }
                    tmp.Add(s);

                    var hoge = tmp.ToArray();
                    for(int i = 0; i < tmp.Count; i++)
                    {
                        for(int j = 0; j < tmp.Count; j++)
                        {
                            haschecked[hoge[i]][hoge[j]] = true;
                        }
                    }

                }
            }

            var ans = M - set.Count;
            Console.WriteLine(ans);

        }
    }

    class Pair : IComparable<Pair>
    {
        public Pair(int node, int cost)
        {
            Node = node; Cost = cost;
        }
        public int Node { get; set; }
        public int Cost { get; set; }
        public int CompareTo(Pair p)
        {
            return p.Cost > Cost ? 1 : -1;
        }
    }

    class PriorityQueue<T> where T : IComparable<T>
    {
        public PriorityQueue()
        {
            buffer = new List<T>();
        }

        List<T> buffer;
        public void Push(T elem)
        {
            int n = buffer.Count;
            buffer.Add(elem);
            while (n != 0)
            {
                int i = (n - 1) / 2;
                if (buffer[n].CompareTo(buffer[i]) > 0)
                {
                    T temp = buffer[n];
                    buffer[n] = buffer[i];
                    buffer[i] = temp;
                }
                n = i;
            }
        }

        public void Pop()
        {
            int n = buffer.Count - 1;
            buffer[0] = buffer[n];
            buffer.RemoveAt(n);
            for (int i = 0, j; (j = 2 * i + 1) < n;)
            {
                if ((j != n - 1) && (buffer[j].CompareTo(buffer[j + 1]) < 0)) { j++; }
                if (buffer[i].CompareTo(buffer[j]) < 0)
                {
                    T temp = buffer[j];
                    buffer[j] = buffer[i];
                    buffer[i] = temp;
                }
                i = j;
            }
        }

        public T Peek()
        {
            return buffer[0];
        }

        public int Count { get { return buffer.Count; } }
    }

    public static class Ex
    {
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
    }

    partial class Program
    {
        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
        static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
        static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
        static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
        static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
        static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H).Select(s => Enumerable.Repeat(value, W).ToArray()).ToArray(); }
        static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetIntArray().ToArray()).ToArray(); }
        static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetLongArray().ToArray()).ToArray(); }
        static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetStr().ToCharArray()).ToArray(); }
        static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); }


        static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
        }
        static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
        }
    }
}

Measured memory_bytes: 18372