#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const double PI = acos(-1);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
const int MAX = 510000;
int dist[110][110];
int a[100], b[100], c[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < n; ++j) {
      dist[i][j] = MOD;
      dist[i][i] = 0;
    }
  for (long long i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    chmin(dist[a[i]][b[i]], c[i]);
    chmin(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) {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
      }
  int ans = m;
  for (long long i = 0; i < m; ++i) {
    bool ok = false;
    for (long long j = 0; j < n; ++j)
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) ok = true;
    if (ok) ans--;
  }
  cout << ans << '\n';
  return 0;
}
