#include <bits/stdc++.h>
int d[100][100];
int next[100][100];
int v[100][100] = {0};
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] != 100000 && d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          next[i][j] = next[i][k];
        }
}
void fill(int start, int end) {
  for (int c = start; c != end; c = next[c][end])
    v[c][next[c][end]] = v[next[c][end]][c] = 1;
}
int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      next[i][j] = j;
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 100000;
    }
  }
  for (int i = 0; i < n; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = d[b][a] = c;
  }
  wf(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) fill(i, j);
  int a = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (v[i][j] == 0 && d[i][j] != 100000) {
        a++;
      }
  std::cout << a << std::endl;
  return 0;
}
