#include <bits/stdc++.h>
using namespace std;
static const int INF = 2000000000;
int main() {
  int n, m;
  cin >> n >> m;
  int a[1000], b[1000], c[1000], d[100][100];
  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)
        d[i][j] = 0;
      else
        d[i][j] = INF;
    }
  }
  for (int i = 0; i < m; i++) {
    d[a[i]][b[i]] = min(c[i], d[a[i]][b[i]]);
    d[b[i]][a[i]] = min(c[i], d[b[i]][a[i]]);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = m;
  for (int i = 0; i < m; i++) {
    int s = 0;
    for (int j = 0; j < n; j++)
      if (d[j][a[i]] + c[i] == d[j][b[i]]) s = 1;
    ans -= s;
  }
  cout << ans << endl;
}
