#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m], c[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  int dis[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        dis[i][j] = 0;
      else
        dis[i][j] = inf;
    }
  }
  for (int i = 0; i < m; i++) {
    dis[a[i]][b[i]] = min(dis[a[i]][b[i]], c[i]);
    dis[b[i]][a[i]] = dis[a[i]][b[i]];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int res = m;
  for (int i = 0; i < m; i++) {
    bool flag = false;
    for (int j = 0; j < n; j++) {
      if (dis[j][a[i]] + c[i] == dis[j][b[i]]) flag = true;
    }
    if (flag) res--;
  }
  cout << res << endl;
}
