#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> graph(N, vector<int>(N, 987654321));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  auto graph_backup = graph;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
  int ans = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (graph_backup[i][j] != 987654321 && graph[i][j] < graph_backup[i][j])
        ans++;
  cout << ans / 2 << endl;
  return 0;
}
