#include <bits/stdc++.h>
using namespace std;
const long long N = 105, inf = 1e17;
long long a[N], b[N], c[N], dist[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, ans = 0;
  cin >> n >> m;
  for (long long i = 0; i < m; i++)
    cin >> a[i] >> b[i] >> c[i], a[i] -= 1, b[i] -= 1;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) dist[i][j] = (i == j ? 0 : inf);
  for (long long i = 0; i < m; i++)
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
  for (long long i = 0; i < m; i++)
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (long long i = 0, chk = 0; i < m; i++, chk = 0) {
    for (long long j = 0; j < n; j++)
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) chk = 1;
    ans += chk;
  }
  cout << m - ans;
}
