#include <bits/stdc++.h>
using namespace std;
template <typename T>
void MACRO_VAR_Scan(T& t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First& first, Rest&... rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int n, m;
  MACRO_VAR_Scan(n, m);
  ;
  int d[n][n], a[m], b[m], c[m];
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (n); j++) d[i][j] = (i == j ? 0 : 100001);
  for (int i = 0; i < (m); i++) {
    int s, t, u;
    MACRO_VAR_Scan(s, t, u);
    ;
    s--;
    t--;
    d[s][t] = d[t][s] = u;
    a[i] = s;
    b[i] = t;
    c[i] = u;
  }
  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 ans = 0;
  for (int i = 0; i < (m); i++) {
    int f = 1;
    for (int j = 0; j < (m); j++)
      if (d[j][a[i]] + c[i] == d[j][b[i]]) f = 0;
    ans += f;
  }
  cout << (ans) << endl;
  ;
  return 0;
  ;
}
