#include <bits/stdc++.h>
using namespace std;
vector<tuple<int, int, int>> vertex[1000];
int oops[10000] = {};
int main() {
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    vertex[a].push_back(make_tuple(b, c, i));
    vertex[b].push_back(make_tuple(a, c, i));
  }
  for (int i = 1; i <= n; ++i) {
    pair<int, int> shortest[1000] = {};
    int done[1000] = {};
    for (long long q = 0; q < 1000; ++q) {
      shortest[q].first = 100000000;
    }
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        hogee;
    hogee.push(make_pair(0, i));
    shortest[i].first = 0;
    shortest[i].second = -1;
    while (hogee.empty() == false) {
      pair<int, int> wow = hogee.top();
      hogee.pop();
      if (done[wow.second] == false) {
        done[wow.second] = true;
        for (int q = 0; q < vertex[wow.second].size(); ++q) {
          if (wow.first + get<1>(vertex[wow.second][q]) <=
              shortest[get<0>(vertex[wow.second][q])].first) {
            shortest[get<0>(vertex[wow.second][q])].first =
                wow.first + get<1>(vertex[wow.second][q]);
            shortest[get<0>(vertex[wow.second][q])].second =
                get<2>(vertex[wow.second][q]);
            hogee.push(make_pair(shortest[get<0>(vertex[wow.second][q])].first,
                                 get<0>(vertex[wow.second][q])));
          }
        }
      }
    }
    for (int j = 1; j <= n; ++j) {
      if (i != j) {
        oops[shortest[j].second] = true;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    if (oops[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
