#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const long long INF = 1e18 + 7;
long long mod = 1e9 + 7;
struct edge {
  long long x, y, z;
};
long long a[200][200];
queue<edge> G;
signed main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  fill((long long*)a, (long long*)(a + 100), inf);
  for (long long i = 0; i < 200; i++) a[i][i] = 0;
  for (long long i = 0; i < m; i++) {
    long long x, y, z;
    scanf("%lld%lld%lld", &x, &y, &z);
    G.push((edge){x, y, z});
    a[x][y] = z;
    a[y][x] = z;
  }
  for (long long i = 1; i < n + 1; i++)
    for (long long j = 1; j < n + 1; j++)
      for (long long k = 1; k < n + 1; k++) {
        a[j][k] = min(a[j][k], a[j][i] + a[i][k]);
      }
  long long ans = m;
  for (long long i = 0; i < m; i++) {
    edge e = G.front();
    G.pop();
    long long f = 0;
    for (long long j = 1; j < n + 1; j++)
      if (e.z + a[e.x][j] == a[e.y][j]) f = 1;
    if (e.z == a[e.x][e.y]) f = 1;
    ans -= f;
  }
  printf("%lld\n", ans);
  return 0;
}
