#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<pair<int, int>, bool> answer;
  vector<pair<int, int>> v[2000];
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    answer[{a, b}] = false;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
  }
  for (int k = 1; k <= n; k++) {
    pair<int, int> distance[2000];
    bool processed[2000] = {false};
    priority_queue<pair<int, int>> q;
    for (int i = 0; i <= n; i++) distance[i].first = 1000000000;
    distance[k].first = 0;
    q.push({0, k});
    while (!q.empty()) {
      int a = q.top().second;
      q.pop();
      if (processed[a] == true) continue;
      processed[a] = false;
      for (auto nei : v[a]) {
        if (distance[nei.first].first > distance[a].first + nei.second) {
          distance[nei.first].first = distance[a].first + nei.second;
          distance[nei.first].second = a;
          q.push({-distance[nei.first].first, nei.first});
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      int j = distance[i].second;
      if (distance[i].first < 1000000000) {
        answer[{min(i, j), max(i, j)}] = true;
      }
    }
  }
  int count = 0;
  for (auto a : answer) {
    if (a.second == false) count++;
  }
  cout << count;
  return 0;
}
