import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	int m = rint;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);
	
	const long infty = 10_000_999;
	
	foreach(x; nodes) foreach(y; nodes){
		if(x.id == y.id) x.costTo[y.id] = 0;
		else x.costTo[y.id] = infty;
	}
	
	
	Edge[] edges;
	foreach(j; 0 .. m){
		int a = rint - 1, b = rint - 1;
		long c = rlong;
		edges ~= new Edge(nodes[a], nodes[b], c);
	}
	edges.sort!"a.cost<b.cost"();
	
	foreach(ed; edges){
		ed.connect(nodes);
	}
	
	long ans;
	foreach(ed; edges) if(ed.isWorthless) ans += 1;
	
	ans.writeln;
	
}

class Node{
	int id;
	long[int] costTo;
	this(int id){
		this.id = id;
		this.costTo[this.id] = 0;
	}
}

class Edge{
	Node a, b;
	long cost;
	bool isWorthless;
	this(Node a, Node b, long c){
		this.a = a;
		this.b = b;
		this.cost = c;
	}
	void connect(Node[] nodes){
		if(a.costTo[b.id] > this.cost){
			foreach(x; nodes) foreach(y; nodes){
				if(x.costTo[y.id] > x.costTo[a.id] + this.cost + b.costTo[y.id]){
					x.costTo[y.id] = x.costTo[a.id] + this.cost + b.costTo[y.id];
					y.costTo[x.id] = x.costTo[a.id] + this.cost + b.costTo[y.id];
				}
				else if(x.costTo[y.id] > x.costTo[b.id] + this.cost + a.costTo[y.id]){
					x.costTo[y.id] = x.costTo[b.id] + this.cost + a.costTo[y.id];
					y.costTo[x.id] = x.costTo[b.id] + this.cost + a.costTo[y.id];
				}
			}
			a.costTo[b.id] = this.cost;
			b.costTo[a.id] = this.cost;
		}
		else if(a.costTo[b.id] < this.cost){
			this.isWorthless = 1;
		}
	}
}
