#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], t[100][100];
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, t[i][j] = 100000000;
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    MACRO_VAR_Scan(a, b, c);
    ;
    a--;
    b--;
    p[a][b] = p[b][a] = c;
    t[a][b] = t[b][a] = c;
  }
  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;
        t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
      }
  int ans = 0;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (n); j++) {
      if (p[i][j] >= 100000000 || i >= j) continue;
      ans += p[i][j] > t[i][j];
    }
  cout << (ans) << endl;
  ;
  return 0;
  ;
}
