#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int edge[101][101] = {};
  bool isused[101][101];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      isused[i][j] = true;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a][b] = c;
    edge[b][a] = c;
    isused[a][b] = false;
    isused[b][a] = false;
  }
  for (int i = 1; i <= n; i++) {
    vector<int> kyori(n + 1, 1000000007);
    priority_queue<pair<int, pair<int, int> > > qu;
    qu.push(make_pair(0, make_pair(i, 0)));
    while (!qu.empty()) {
      int nowkyori = -(qu.top()).first;
      int nownode = ((qu.top()).second).first;
      int beforenode = ((qu.top()).second).second;
      qu.pop();
      if (nowkyori >= kyori[nownode]) continue;
      kyori[nownode] = nowkyori;
      isused[beforenode][nownode] = true;
      isused[nownode][beforenode] = true;
      for (int j = 1; j <= n; j++) {
        if (edge[nownode][j] > 0) {
          qu.push(
              make_pair(-(nowkyori + edge[nownode][j]), make_pair(j, nownode)));
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (!isused[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
