#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, p[100][100], pp[100][100];
  for (int i = 0; i < 100; i++)
    for (int ii = 0; ii < 100; ii++) p[i][ii] = INT32_MAX / 2;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    p[min(a - 1, b - 1)][max(a - 1, b - 1)] = c;
  }
  memcpy(pp, p, sizeof(int[100][100]));
  for (int a = 0; a < n; a++) {
    for (int b = a + 1; b < n; b++) {
      for (int c = 0; c < n; c++) {
        pp[a][b] =
            min(pp[a][b], pp[min(a, c)][max(a, c)] + pp[min(b, c)][max(b, c)]);
      }
    }
  }
  int res = 0;
  for (int a = 0; a < n; a++) {
    for (int b = a + 1; b < n; b++) {
      if (p[a][b] != INT32_MAX / 2 && p[a][b] != pp[a][b]) {
        res++;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
