#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int S[n][n];
  int INF = numeric_limits<int>::infinity();
  int a[m], b[m], c[m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      S[i][j] = INF;
      if (i == j) S[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    S[s - 1][t - 1] = w;
    S[t - 1][s - 1] = w;
    a[i] = s - 1;
    b[i] = t - 1;
    c[i] = w;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        S[i][j] = min(S[i][j], S[i][k] + S[k][j]);
      }
    }
  }
  int out = m;
  for (int x = 0; x < m; x++) {
    for (int i = 0; i < n; i++) {
      if (S[i][a[x]] + c[x] == S[i][b[x]]) {
        out--;
        break;
      }
    }
  }
  cout << out << endl;
  return 0;
}
