#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
template <class T>
ostream &operator<<(std::ostream &o, const vector<T> &v) {
  for (int i = 0; i < v.size(); i++) {
    o << (i > 0 ? " " : "") << v[i];
  }
  return o;
}
int main() {
  int n, m, a, b, c, ans = 0;
  cin >> n >> m;
  vi av, bv, cv;
  vvi dist(n, vi(n, INT_MAX / 2));
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    av.push_back(a);
    bv.push_back(b);
    cv.push_back(c);
    dist[a - 1][b - 1] = c;
    dist[b - 1][a - 1] = c;
  }
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    if (dist[av[i] - 1][bv[i] - 1] != cv[i]) ans++;
  }
  cout << ans << endl;
}
