#include <cstdio>
#include <algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_M = 1000, MAX_N = 100, INF = std::numeric_limits<int>::max()>>2;

int N, M;
int a[MAX_M], b[MAX_M], c[MAX_M];
int d[MAX_N][MAX_N];

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
    scanf( "%d%d%d", a+i, b+i, c+i ), --a[i], --b[i];

  std::fill( (int*)d, (int*)(d+N), INF );
  rep( i, M )
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  rep( i, N )
    d[i][i] = 0;

  rep( k, N ) rep( i, N ) rep( j, N )
    d[i][j] = std::min( d[i][j], d[i][k]+d[k][j] );

  int ans = 0;
  rep( i, M ) if( d[a[i]][b[i]] < c[i] )
    ++ans;

  printf( "%d\n", ans );

  return 0;
}