#include <bits/stdc++.h>
using namespace std;
vector<vector<long>> dist;
short Warshall_Floyd(long V) {
  for (int i = 0; i < (V + 1); i++) dist[i][i] = 0;
  for (int i = (1); i < (V + 1); i++) {
    for (int j = (1); j < (V + 1); j++) {
      for (int k = (0); k < (V); k++) {
        if (dist[j][i] == 2147483647 || dist[i][k] == 2147483647) continue;
        if (dist[j][k] > dist[j][i] + dist[i][k]) {
          dist[j][k] = dist[j][i] + dist[i][k];
        }
        if (dist[j][j] < 0) return (-1);
      }
    }
  }
  return 0;
}
int main(void) {
  long V, E;
  cin >> V >> E;
  dist = vector<vector<long>>(V + 1, vector<long>(V + 1, 2147483647));
  for (int i = 0; i < (E); i++) {
    long v1, v2, dis;
    cin >> v1 >> v2 >> dis;
    dist[v1][v2] = dis;
    dist[v2][v1] = dis;
  }
  vector<vector<long>> e = dist;
  long retval = Warshall_Floyd(V);
  long cnt = 0;
  for (int i = (1); i < (V + 1); i++) {
    for (int j = (1); j < (V + 1); j++) {
      if (e[i][j] != 2147483647 && e[i][j] > dist[i][j]) cnt++;
    }
  }
  cout << cnt << endl;
}
