#include <bits/stdc++.h>
using namespace std;
const int L = 101;
const int inf = 1e8;
int a[L];
int b[L];
int c[L];
int dist[L][L];
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = inf;
    }
    dist[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    scanf("%d%d%d", a + i, b + i, c + i);
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < M; i++) {
    if (dist[a[i]][b[i]] < c[i]) {
      ret++;
    }
  }
  printf("%d\n", ret);
  return 0;
}
