//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, E, C;
	List<E> all;
	List<E>[] es;
	void Solve()
	{
		var I = G();
		V = I[0];
		E = I[1];
		all = new List<E>();
		es = new List<E>[V];
		for (var i = 0; i < V; i++) es[i] = new List<E>();
		for (var i = 0; i < E; i++)
		{
			I = G();
			AddEdge(I[0] - 1, I[1] - 1, I[2]);
		}
		var d = new int[V, V];
		for (var i = 0; i < V; i++)
		{
			var e = DijkstraFrom(0);
			for (var j = 0; j < V; j++) d[i, j] = e[j];
		}
		var c = E;
		foreach (var e in all)
		{
			var flag = false;
			for (var i = 0; i < V; i++)
				if (d[i, e.From] + e.Cost == d[i, e.To])
				{
					flag = true;
					break;
				}
			if (flag) c--;
		}
		WriteLine(c);
	}
	void AddEdge(int f, int t, int c)
	{
		var e = new E(f, t, c);
		es[f].Add(e);
		es[t].Add(new E(t, f, c));
		all.Add(e);
		C = Max(C, c);
	}
	int[] DijkstraFrom(int from)
	{
		var d = Enumerable.Repeat(MOD, V).ToArray();
		var queue = new DialQueue(C);
		d[from] = 0;
		queue.Add(from, 0);
		while (queue.Any)
		{
			var p = queue.Pop();
			var v = p.To;
			if (d[v] < p.Cost) continue;
			foreach (var e in es[v])
			{
				var tmp = d[v] + e.Cost;
				if (d[e.To] > tmp)
				{
					if (d[e.To] != MOD) queue.Move(e.To, d[e.To], tmp);
					else queue.Add(e.To, tmp);
					d[e.To] = tmp;
				}
			}
		}
		return d;
	}
}
struct E
{
	public int From, To, Cost;
	public E(int f, int t, int c)
	{
		From = f;
		To = t;
		Cost = c;
	}
	public override string ToString()
	{
		return string.Format("From = {0}, To = {1}, Cost = {2}", From, To, Cost);
	}
}
class DialQueue
{
	public int Count { get; private set; }
	int C, offset;
	HashSet<int>[] buckets;
	HashSet<int> this[int n] { get { return buckets[(n - offset + offset % C) % C]; } }
	public DialQueue(int c)
	{
		C = c + 1;
		buckets = new HashSet<int>[C];
		for (var i = 0; i < C; i++) buckets[i] = new HashSet<int>();
	}
	public void Add(int v, int d)
	{
		Count++;
		this[d].Add(v);
	}
	public void Move(int v, int prev, int now)
	{
		this[prev].Remove(v);
		this[now].Add(v);
	}
	public bool Any { get { return Count > 0; } }
	public E Pop()
	{
		Count--;
		var t = offset;
		while (true)
		{
			var s = this[t];
			if (s.Count > 0)
			{
				var v = s.First();
				s.Remove(v);
				offset = t;
				return new E(-1, v, t);
			}
			t++;
		}
	}
	public override string ToString()
	{
		return string.Format("C = {0}, Offset = {1}, count = {2}", C, offset, Count);
	}
}
