#include <bits/stdc++.h>
int d[100][100];
int e[100][100];
void wf(int v) {
  for (int k = 0; k < v; k++)
    for (int i = 0; i < v; i++)
      for (int j = 0; j < v; j++)
        if (d[i][j] != 1e+9 && d[k][j] != 1e+9)
          d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
}
int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        e[i][j] = d[i][j] = 0;
      else
        e[i][j] = d[i][j] = 1e+9;
    }
  }
  for (int i = 0; i < n; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    a--;
    b--;
    e[a][b] = e[b][a] = d[a][b] = d[b][a] = c;
  }
  wf(n);
  int a = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (d[i][j] < e[i][j]) a++;
  std::cout << a << std::endl;
  return 0;
}
