#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
int MAX_V = 100;
vector<vector<int>> d(MAX_V, vector<int>(MAX_V, INF));
void warshall_floyd() {
  for (int k = 0; k < MAX_V; ++k)
    for (int i = 0; i < MAX_V; ++i)
      for (int j = 0; j < MAX_V; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> prev(MAX_V, vector<int>(MAX_V, INF));
  vector<int> a(n), b(n), c(n);
  for (long long(i) = 0; (i) < (m); (i)++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (long long(i) = 0; (i) < (n); (i)++) d[i][i] = 0;
  warshall_floyd();
  int ans = m;
  for (long long(i) = 0; (i) < (m); (i)++) {
    bool used = false;
    for (long long(j) = 0; (j) < (n); (j)++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) used = true;
    }
    if (used) ans--;
  }
  cout << ans << endl;
}
