#include <bits/stdc++.h>
using namespace std;
int g[105][105];
void init() {
  for (int i = 0; i < 105; ++i) memset(g[i], 1e9, sizeof(g[i]));
}
int main() {
  init();
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a][b] = g[b][a] = c;
  }
  int cnt = 0;
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        if (g[i][k] + g[k][j] < g[i][j]) {
          ++cnt;
          g[i][j] = g[i][k] + g[k][j];
        }
      }
  if (cnt > 0)
    cout << cnt - 1;
  else
    printf("0");
  return 0;
}
