#include <bits/stdc++.h>
using namespace std;
long long d[101][101];
int n, m;
void wf() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 10e10;
    }
  }
  std::vector<pair<long long, long long> > E;
  for (int i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    pair<long long, long long> p;
    p.first = a - 1;
    p.second = b - 1;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
    E.push_back(p);
  }
  wf();
  long long ans = m;
  for (int e = 0; e < m; ++e) {
    bool flag = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        if (d[i][j] == d[i][E[e].first] + d[j][E[e].second]) {
          flag = false;
        }
      }
    }
    if (flag) ans--;
  }
  cout << ans << endl;
}
