#include <bits/stdc++.h>
using namespace std;
int N, M;
int ab[100][100];
set<pair<int, int>> use;
int dijkstra(int k) {
  vector<int> dist(N, 100000);
  vector<vector<int>> prev(N);
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  dist[k] = 0;
  que.push({0, k});
  while (!que.empty()) {
    auto cur = que.top().second;
    que.pop();
    for (int i = 0; i < N; i++) {
      if (ab[cur][i] == 0) continue;
      if (dist[cur] + ab[cur][i] < dist[i]) {
        dist[i] = dist[cur] + ab[cur][i];
        que.push({dist[i], i});
        prev[i].clear();
        prev[i].push_back(cur);
      } else if (dist[cur] + ab[cur][i] == dist[i]) {
        prev[i].push_back(i);
      }
    }
  }
  for (int v = 0; v < N; v++) {
    for (auto u : prev[v]) {
      use.insert(make_pair(min(u, v), max(u, v)));
    }
  }
  return 0;
}
int solve() {
  for (int i = 0; i < N; i++) {
    dijkstra(i);
  }
  cout << M - (int)use.size() << endl;
  return 0;
}
int main() {
  int a, b, c;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    ab[a][b] = c;
    ab[b][a] = c;
  }
  solve();
  return 0;
}
