#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> g(n, vector<long long>(n, inf));
  for (int i = (0); i < (n); i++) g[i][i] = 0;
  vector<long long> a(m, 0);
  vector<long long> b(m, 0);
  vector<long long> c(m, 0);
  for (int i = (0); i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    g[a[i]][b[i]] = c[i];
    g[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    if (g[a[i]][b[i]] == c[i]) ans--;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
