#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n, m;
  cin >> n >> m;
  int adj[101][101];
  int dist[101][101] = {};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dist[i][j] = adj[i][j] = 1 << 25;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    adj[a][b] = c;
    adj[b][a] = c;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dist[i][j] = adj[i][j];
  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] + adj[k][j]);
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (dist[i][j] < adj[i][j] && adj[i][j] != 1 << 25) ans++;
  cout << ans << endl;
}
