#include <bits/stdc++.h>
using namespace std;
inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; }
vector<vector<int> > d;
vector<vector<int> > G;
int V, E;
void warshall_floyd() {
  for (int k = 0, k_max = (V); k < k_max; ++k)
    for (int i = 0, i_max = (V); i < i_max; ++i)
      for (int j = 0, j_max = (V); j < j_max; ++j)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(15);
  cin >> V >> E;
  d = vector<vector<int> >(V, vector<int>(V, INT_MAX));
  G = vector<vector<int> >(V, vector<int>(V, INT_MAX));
  for (int i = 0, i_max = (E); i < i_max; ++i) {
    int f, t, c;
    cin >> f >> t >> c;
    --f;
    --t;
    d[f][t] = d[t][f] = G[f][t] = G[t][f] = c;
  }
  for (int i = 0, i_max = (V); i < i_max; ++i) d[i][i] = 0;
  warshall_floyd();
  int count = 0;
  for (int i = 0, i_max = (V); i < i_max; ++i)
    for (int j = (i + 1), j_max = (V); j < j_max; ++j)
      if (G[i][j] != INT_MAX && G[i][j] != d[i][j]) ++count;
  cout << count << endl;
  return 0;
}
