#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...);
}
int p[100][100], a[1000], b[1000], c[1000];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int n, m;
  MACRO_VAR_Scan(n, m);
  ;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++) p[i][j] = 100000000;
  for (int i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    p[a[i]][b[i]] = p[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < (n); k++)
    for (int i = 0; i < (n); i++)
      for (int j = 0; j < (n); j++) {
        if (i == j) continue;
        p[i][j] = min(p[i][j], p[i][k] + p[k][j]);
      }
  int ans = 0;
  for (int k = 0; k < (m); k++) {
    int f = 1;
    for (int i = 0; i < (n); i++) {
      if (i == a[k] || i == b[k]) continue;
      if (p[i][b[k]] == p[i][a[k]] + c[k]) f = 0;
      if (p[i][a[k]] == p[i][b[k]] + c[k]) f = 0;
    }
    ans += f;
  }
  cout << (ans) << endl;
  ;
  return 0;
  ;
}
