#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[101], B[101], R[101];
vector<pair<int, int>> E[101];
int mat[101][101];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M;
  for (x = 0; x < (N); x++)
    for (y = 0; y < (N); y++) mat[x][y] = (x == y) ? 0 : 1 << 25;
  for (i = 0; i < (M); i++) {
    cin >> A[i] >> B[i] >> R[i];
    A[i]--;
    B[i]--;
    mat[A[i]][B[i]] = mat[B[i]][A[i]] = R[i];
  }
  for (k = 0; k < (N); k++)
    for (i = 0; i < (N); i++)
      for (j = 0; j < (N); j++)
        mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
  int ng = 0;
  for (i = 0; i < (M); i++) {
    int ok = 0;
    for (x = 0; x < (N); x++)
      for (y = 0; y < (N); y++) {
        if (mat[x][y] == mat[x][A[i]] + mat[B[i]][y] + R[i]) ok = 1;
        if (mat[x][y] == mat[x][B[i]] + mat[A[i]][y] + R[i]) ok = 1;
      }
    if (ok == 0) ng++;
  }
  cout << ng << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
