#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, k;
  int n, m;
  cin >> n >> m;
  int v[100][100];
  int x[100], y[100], z[100];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (i == j)
        v[i][j] = 0;
      else
        v[i][j] = 1e9;
  for (i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    x[i] = a;
    y[i] = b;
    z[i] = c;
    v[a][b] = c;
    v[b][a] = c;
  }
  for (k = 0; k < n; k++)
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
  int ans = 0;
  for (i = 0; i < m; i++)
    if (v[x[i]][y[i]] < z[i]) ans++;
  cout << ans << endl;
}
