#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N), C(N);
  vector<vector<int>> dist(N, vector<int>(N));
  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) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 1000000000;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    dist[A[i]][B[i]] = min(dist[A[i]][B[i]], C[i]);
    dist[B[i]][A[i]] = min(dist[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++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int res = M;
  for (int i = 0; i < M; i++) {
    bool flag = false;
    for (int j = 0; j < N; j++) {
      if (dist[j][A[i]] + C[i] == dist[j][B[i]]) {
        flag = true;
      }
    }
    if (flag) {
      res--;
    }
  }
  cout << res << endl;
  return 0;
}
