#include <bits/stdc++.h>
using ll = long long;
static const ll mod = 1e9 + 7;
static ll INF = 1e9;
using namespace std;
int d[105][105];
int n;
void warshall_floyd() {
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}
signed main() {
  int m;
  cin >> n >> m;
  int ans = 0;
  for (int i = (int)0; i < (int)n + 1; ++i)
    for (int j = (int)0; j < (int)n + 1; ++j) {
      d[i][j] = 10000;
    }
  vector<int> a(m), b(m), c(m);
  for (int i = (int)0; i < (int)m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    --c[i];
  }
  warshall_floyd();
  for (int i = (int)0; i < (int)m; ++i) {
    bool judge = false;
    for (int j = (int)0; j < (int)n; ++j) {
      for (int k = (int)0; k < (int)n; ++k) {
        if (d[j][k] == d[j][a[i]] + c[i] + d[b[i]][k]) judge = true;
      }
    }
    if (!judge) ++ans;
  }
  cout << ans << endl;
  return 0;
}
