#include <bits/stdc++.h>
using lint = int64_t;
using namespace std;
int main() {
  int N, M;
  int a[110] = {};
  int b[110] = {};
  int c[110] = {};
  int mat[110][110] = {};
  for (int i = 0; i < 110; i++)
    for (int j = 0; j < 110; j++)
      if (i != j) mat[i][j] = 1e7;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    mat[a[i]][b[i]] = min(mat[a[i]][b[i]], c[i]);
    mat[b[i]][a[i]] = min(mat[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++)
        mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
  int ans = M;
  for (int k = 0; k < M; k++) {
    bool isneed = false;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int dist =
            min(mat[i][a[k]] + mat[b[k]][j], mat[i][b[k]] + mat[a[k]][j]);
        if (dist + c[k] == mat[i][j]) isneed = true;
      }
    }
    if (isneed) ans--;
  }
  cout << ans << endl;
  return 0;
}
