#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  int G[105][105];
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 105; j++) {
      G[i][j] = INT_MAX;
    }
  }
  for (int i = 0; i < N; i++) G[i][i] = 0;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G[a[i]][b[i]] = c[i];
    G[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int ans = 0;
  vector<int> count(M, 0);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (G[j][k] == G[j][a[i]] + G[a[i]][b[i]] + G[b[i]][k]) {
          if (k != b[i] || j != a[i]) count[i]++;
        }
      }
    }
  }
  for (int i = 0; i < M; i++) {
    if (count[i] > 0) ans++;
  }
  cout << M - ans << endl;
}
