using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = ReadIntArray();
            var n = nm[0];
            var m = nm[1];
            var r = new Dictionary<Tuple<int, int>, int>();
            for (int i = 0; i < m; i++)
            {
                var abc = ReadIntArray();
                var a = abc[0] - 1;
                var b = abc[1] - 1;
                var c = abc[2];
                r.Add(Tuple.Create(Math.Min(a, b), Math.Max(a, b)), c);
            }
            var count = 0;
            foreach (var item in r)
            {
                var a = item.Key.Item1;
                var b = item.Key.Item2;
                for (int i = 0; i < n; i++)
                {
                    if (i != a && i != b)
                    {
                        if (r.TryGetValue(Tuple.Create(Math.Min(a, i), Math.Max(a, i)), out var line1) && r.TryGetValue(Tuple.Create(Math.Min(b, i), Math.Max(b, i)), out var line2))
                        {
                            if (item.Value > line1 + line2)
                            {
                                count++;
                            }
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}
