var
 a,b:array[1..100,1..100] of longint;
 i,j,x,y,n,m,k,t,s,z:longint;
begin
 read(n,m);
 fillchar(a,sizeof(a),$7f);
 for i:=1 to m do
  begin
   read(x,y,z);
   a[x,y]:=z;
   a[y,x]:=z;
   b[x,y]:=1;
  end;
 for k:=1 to n do
  for i:=1 to n do
   for j:=1 to n do
    if (i<>j)and(i<>k)and(j<>k)and(a[i,j]>a[i,k]+a[k,j]) then
     begin
      a[i,j]:=a[i,k]+a[k,j];
      b[i,k]:=0;
      b[k,j]:=0;
      t:=1;
     end;
 for i:=1 to 100 do
  for j:=1 to 100 do
   if (b[i,j]=1) then s:=s+1;
 if (t=0) then s:=0;
 writeln(s);
end.