#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void gn(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
template <typename T>
inline void gt(T x) {
  if (!x) return;
  gt(x / 10);
  putchar(x % 10 + '0');
}
const long long MAXN = 1e2 + 5;
long long t, n, m, q, ans;
long long MOD = 1e9 + 7, inf = 0x3f3f3f3f;
double eps = 1e-5;
long long f[111][111], a[1111], b[1111], c[1111];
int main() {
  long long i, j, k, l, ca = 0, u, v, w;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) f[i][j] = (i == j ? 0 : inf);
  for (i = 1; i <= m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    f[a[i]][b[i]] = min(f[a[i]][b[i]], c[i]);
    f[b[i]][a[i]] = min(f[b[i]][a[i]], c[i]);
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      for (k = 1; k <= n; k++) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  for (j = 1; j <= m; j++) {
    k = 0;
    for (i = 1; i <= n; i++) {
      if (f[i][b[j]] == f[i][a[j]] + c[j]) k = 1;
    }
    ans += k;
  }
  ans = m - ans;
  cout << ans << endl;
  return 0;
}
