#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
int N, M;
int A[100][100];
int a, b, c;
queue<tuple<int, int, int> > q;
int main(void) {
  cin >> N >> M;
  fill_n(A[0], N * N, INF);
  for (int i = 0; i < M; ++i) {
    cin >> a >> b >> c;
    --a;
    --b;
    A[a][b] = A[b][a] = c;
    q.push(tuple<int, int, int>(a, b, c));
  }
  for (int k = 0; k < N; ++k)
    for (int i = 0; i < N; ++i)
      for (int j = 0; j < N; ++j) A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
  int ans = M;
  while (!q.empty()) {
    tie(a, b, c) = q.front();
    q.pop();
    if (A[a][b] == c) --ans;
  }
  cout << ans << endl;
  return 0;
}
