#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int graph[N][N];
  int A[M];
  int B[M];
  int C[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        graph[i][j] = 0;
      } else {
        graph[i][j] = INT_MAX;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    graph[A[i]][B[i]] = min(graph[A[i]][B[i]], C[i]);
    graph[B[i]][A[i]] = min(graph[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++) {
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  int ans = M;
  for (int i = 0; i < M; i++) {
    int FLAG = 0;
    for (int j = 0; j < N; j++) {
      if (graph[j][A[i]] + C[i] == graph[j][B[i]]) {
        FLAG = 1;
      }
    }
    if (FLAG == 1) ans--;
  }
  cout << ans;
}
