#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-4;
int n, m;
int a[101];
int b[101];
int c[101];
int d[101][101];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= int(m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 1; i <= int(n); ++i)
    for (int j = 1; j <= int(n); ++j) d[i][j] = i == j ? 0 : inf;
  for (int i = 1; i <= int(m); ++i) {
    d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
    d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
  }
  for (int k = 1; k <= int(n); ++k)
    for (int i = 1; i <= int(n); ++i)
      for (int j = 1; j <= int(n); ++j)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = 0;
  for (int i = 1; i <= int(m); ++i) {
    if (d[a[i]][b[i]] != c[i]) ++ans;
  }
  cout << ans;
}
