#include <bits/stdc++.h>
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;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const long long INF = 1LL << 60;
const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  int dist[n][n];
  memset(dist, 1e9, sizeof(dist));
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) chmin(dist[i][j], dist[i][k] + dist[k][j]);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    bool ok = true;
    for (int s = 0; s < n; s++)
      if (dist[s][a[i]] + c[i] == dist[s][b[i]]) ok = false;
    if (ok) ans++;
  }
  std::cout << ans << '\n';
}
