import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto edge = new long[2][][](N);
	auto use  = new long[][](N, N);
	foreach (i; 0..N) fill(use[i], -1);
	foreach (i; 0..M)
	{
		auto a = RD-1;
		auto b = RD-1;
		auto c = RD;
		edge[a] ~= [b, c];
		edge[b] ~= [a, c];
		use[a][b] = 0;
		use[b][a] = 0;
	}

	long[][] f(long from)
	{
		auto path = new long[][](N);
		auto cost = new long[](N);
		fill(cost, long.max);
		long[] open = [from];
		path[from] = [from];
		cost[from] = 0;
		while (!open.empty)
		{
			auto n = open.front; open.popFront;
			foreach (e; edge[n])
			{
				auto pos = e[0];
				auto c   = e[1] + cost[n];
				if (c < cost[pos])
				{
					path[pos] = path[n] ~ pos;
					cost[pos] = c;
					open ~= pos;
				}
			}
		}
		return path;
	}

	foreach (i; 0..N)
	{
		auto r = f(i);
		foreach (e; r)
		{
			foreach (j; 0..e.length-1)
			{
				use[e[j]][e[j+1]] = 1;
				use[e[j+1]][e[j]] = 1;
			}
		}
	}
	long ans;
	foreach (e; use)
	{
		foreach (ee; e)
		{
			if (ee == 0) ++ans;
		}
	}
	
	writeln(ans / 2);
	stdout.flush();
}