#include <bits/stdc++.h>
using namespace std;
int d[100][100];
vector<pair<int, int>> g[100];
void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  for (int i = 0; i < 100; i++) d[s][i] = 100100100;
  d[s][s] = 0;
  que.push({0, s});
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    int v = p.second;
    if (d[s][v] < p.first) continue;
    for (int i = 0; i < g[v].size(); i++) {
      auto e = g[v][i];
      if (d[s][e.second] > d[s][v] + e.first) {
        d[s][e.second] = d[s][v] + e.first;
        que.push({d[s][e.second], e.second});
      }
    }
  }
}
int main(void) {
  int n, m;
  int a[100], b[100], c[100];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    g[a[i]].push_back({c[i], b[i]});
    g[b[i]].push_back({c[i], a[i]});
  }
  for (int i = 0; i < n; i++) dijkstra(i);
  int ans = m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
}
