#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
const double EPS = 1e-11;
const int INF = 1e9;
const int MAX_V = 114;
int d[MAX_V][MAX_V];
int V;
void warshall_floyd() {
  for (int k = 0; k < (V); ++k) {
    for (int i = 0; i < (V); ++i) {
      for (int j = 0; j < (V); ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, a[1333], b[1333], c[1333];
  cin >> n >> m;
  V = n;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) {
      if (i != j) {
        d[i][j] = INF;
      }
    }
  }
  for (int i = 0; i < (m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  warshall_floyd();
  int ans = m;
  for (int i = 0; i < (m); ++i) {
    bool ok = false;
    for (int j = 0; j < (n); ++j) {
      if (d[j][a[i]] + d[a[j]][b[i]] == d[j][b[i]]) {
        ok = true;
        break;
      }
    }
    if (ok) {
      --ans;
    }
  }
  cout << ans << '\n';
  return 0;
}
