#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  int d[100][100];
  vector<tuple<int, int, int> > edges;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
    edges.push_back(tuple<int, int, int>(a, b, c));
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    tie(a, b, c) = edges[i];
    if (d[a][b] != c) ans++;
  }
  cout << ans << endl;
}
