#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  scanf("%d %d\n", &N, &M);
  vector<vector<int>> edges(N, vector<int>(N, -1));
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    scanf("%d %d %d\n", &a, &b, &c);
    --a;
    --b;
    edges[a][b] = c;
    edges[b][a] = c;
  }
  auto dijkstra = [&](int start, int goal) {
    unordered_map<int, int> costs;
    costs.emplace(start, 0);
    while (true) {
      int next_node;
      int next_cost = INT_MAX;
      for (auto& elem : costs) {
        auto& i = elem.first;
        auto& cost = elem.second;
        for (int j = 0; j < N; ++j) {
          if (costs.count(j) || edges[i][j] == -1 || (i == start && j == goal))
            continue;
          int temp_cost = cost + edges[i][j];
          if (temp_cost < next_cost) {
            next_node = j;
            next_cost = temp_cost;
          }
        }
      }
      if (next_cost == INT_MAX) break;
      costs.emplace(next_node, next_cost);
      if (next_node == goal) break;
    }
    return ((costs.count(goal)) ? costs[goal] : INT_MAX);
  };
  int result = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (edges[i][j] == -1) continue;
      if (dijkstra(i, j) < edges[i][j]) ++result;
    }
  }
  printf("%d\n", result);
}
