#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
struct Edge {
  int cost, to;
  Edge(int to_, int cost_) : to(to_), cost(cost_) {}
};
using Graph = vector<vector<Edge> >;
int main(void) {
  int n, m;
  cin >> n >> m;
  Graph node(n);
  map<std::pair<int, int>, bool> used_path;
  std::vector<std::vector<int> > dist(n, std::vector<int>(n, 1e9));
  std::vector<int> prev(n, -1);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a - 1][b - 1] = c;
    dist[b - 1][a - 1] = c;
    used_path[std::pair<int, int>(a - 1, b - 1)] = false;
  }
  for (int i = 0; i < n; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          prev[j] = k;
        }
      }
    }
  }
  for (int start = 0; start < n; start++) {
    for (int i = 0; i < n; i++) {
      std::vector<int> path;
      if (i == start) {
        continue;
      }
      for (int cur = i; cur != -1; cur = prev[cur]) {
        path.push_back(cur);
      }
      for (int j = 0; j < path.size() - 1; j++) {
        used_path[std::pair<int, int>(path[j], path[j + 1])] = true;
        used_path[std::pair<int, int>(path[j + 1], path[j])] = true;
      }
    }
  }
  int ans = 0;
  for (auto path : used_path) {
    if (!path.second) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
