#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
int d[110][110];
tuple<int, int, int> e[10010];
int n, m;
const int inf = 1e9;
int main() {
  scanf("%d%d", &n, &m);
  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 = 0; i < int(m); ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    e[i] = {u, v, w};
    d[u][v] = d[v][u] = w;
  }
  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 it = 0; it < int(m); ++it) {
    int u, v, w;
    tie(u, v, w) = e[it];
    ans += d[u][v] != w;
  }
  printf("%d\n", ans);
  return 0;
}
