#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(n, vector<int>(n, INF));
  for (int i = 0; i < (int)(n); i++) d.at(i).at(i) = 0;
  vector<tuple<int, int, int>> edge(m);
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d.at(a).at(b) = c;
    d.at(b).at(a) = c;
    edge.at(i) = {a, b, c};
  }
  for (int k = 0; k < (int)(n); k++)
    for (int i = 0; i < (int)(n); i++)
      for (int j = 0; j < (int)(n); j++)
        d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
  int ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    tie(a, b, c) = edge.at(i);
    bool add = true;
    for (int j = 0; j < (int)(n); j++) {
      for (int k = 0; k < (int)(n); k++) {
        int f = d.at(j).at(k);
        int g = c;
        g += d.at(j).at(a);
        g += d.at(b).at(k);
        if (f == g) add = false;
      }
    }
    if (add == true) ans++;
  }
  cout << ans << endl;
  return 0;
}
