#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m=map(int,input().split())\n"
"d=[[10**18]*n for i in range(n)]\n"
"e=[]\n"
"for _ in range(m):\n"
"    a,b,c=map(int,input().split())\n"
"    d[a-1][b-1]=c\n"
"    d[b-1][a-1]=c\n"
"    e.append([a-1,b-1,c])\n"
"for i in range(n):\n"
"    d[i][i]=0\n"
"for k in range(n):\n"
"    for i in range(n):\n"
"        for j in range(n):\n"
"            d[i][j]=min(d[i][j],d[i][k]+d[k][j])\n"
"print(sum(c>d[a][b]for a,b,c in e))\n"
"\"";
  system(s);
  return 0;
}            