#include <bits/stdc++.h>
using namespace std;
long long n, m, d[102][102], L[102], R[102], C[102];
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]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < 102; i++) {
    for (int j = 0; j < 102; j++) {
      d[i][j] = 1000000007;
    }
  }
  for (int i = 0; i < m; i++) {
    int l, r, c;
    cin >> l >> r >> c;
    l--;
    r--;
    d[l][r] = d[r][l] = c;
    L[i] = l;
    R[i] = r;
    C[i] = c;
  }
  warshall_floyd();
  long long ans = m;
  for (int i = 0; i < m; i++) {
    long long nowl = L[i], nowr = R[i], nowc = C[i];
    if (d[nowl][nowr] == nowc) {
      ans--;
    }
  }
  cout << ans;
  return 0;
}
