#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int inf = 1000000;
int d[105][105], graph[105][105];
int main(int argc, const char* argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      graph[i][j] = inf;
      d[i][j] = inf;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--, c--;
    graph[a][b] = graph[b][a] = c;
    d[a][b] = d[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (graph[i][j] == inf) {
        continue;
      }
      if (graph[i][j] != d[i][j]) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
