#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long MOD = 998244353;
long long n, m;
long long cost[101][101];
long long d[101];
void dijkstra(long long x) {
  for (long long i = 1; i <= n; i++) d[i] = 1e9;
  d[x] = 0;
  vector<bool> used(n + 1, false);
  while (true) {
    long long v = -1;
    for (long long i = 1; i <= n; i++) {
      if (!used[i] && (v == -1 || d[i] < d[v])) v = i;
    }
    if (v == -1) break;
    used[v] = true;
    for (long long i = 1; i <= n; i++) {
      d[i] = min(d[i], d[v] + cost[v][i]);
    }
  }
}
int main() {
  cin >> n >> m;
  vector<long long> a(n), b(n), c(n);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      cost[i][j] = (i == j) ? 0 : 1e9;
    }
  }
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    cost[a[i]][b[i]] = cost[b[i]][a[i]] = c[i];
  }
  vector<bool> is(m, false);
  for (long long i = 1; i <= n; i++) {
    dijkstra(i);
    for (long long j = 0; j < m; j++) {
      if ((d[a[j]] + c[j] == d[b[j]]) || (d[a[j]] == d[b[j]] + c[j]))
        is[j] = true;
    }
  }
  long long res = 0;
  for (long long i = 0; i < m; i++) {
    if (!is[i]) res++;
  }
  cout << (res) << endl;
  ;
  return 0;
}
