#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M, cnt = 0;
  cin >> N >> M;
  vector<vector<int> > line(N, vector<int>(N, 1e4));
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  for (int i = (int)0; i < (int)M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    line[--a[i]][--b[i]] = c[i];
    line[b[i]][a[i]] = c[i];
  }
  for (int h = (int)0; h < (int)N; ++h) {
    for (int i = (int)0; i < (int)N; ++i) {
      for (int j = (int)0; j < (int)N; ++j) {
        line[i][j] = min(line[i][j], line[i][h] + line[h][j]);
      }
    }
  }
  for (int i = (int)0; i < (int)M; ++i) {
    if (line[a[i]][b[i]] < c[i]) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}
