#include <bits/stdc++.h>
using lli = long long int;
int inf = 1000000007;
using namespace std;
int N, M;
int main() {
  cin >> N >> M;
  int wf[100][100];
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++) wf[i][j] = (i == j ? 0 : inf);
  vector<int> A;
  vector<int> B;
  vector<int> C;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    A.push_back(a - 1), B.push_back(b - 1), C.push_back(c);
    wf[a - 1][b - 1] = wf[b - 1][a - 1] = c;
  }
  for (int t = 0; t < N; t++)
    for (int s = 0; s < N; s++)
      for (int g = 0; g < N; g++) wf[t][s] = min(wf[t][s], wf[t][g] + wf[g][s]);
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (wf[A[i]][B[i]] < C[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
