#include <bits/stdc++.h>
using namespace std;
int d[100][100];
bool used[100];
int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = (int)0; i < (int)n; ++i)
    for (int j = (int)0; j < (int)n; ++j) d[i][j] = 1000000000;
  for (int i = (int)0; i < (int)n; ++i) d[i][i] = 0;
  int a[1000], b[1000], c[1000];
  for (int i = (int)0; i < (int)m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = (int)0; k < (int)n; ++k)
    for (int i = (int)0; i < (int)n; ++i)
      for (int j = (int)0; j < (int)m; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
  memset(used, false, sizeof(used));
  long long ans = 0;
  for (int i = (int)0; i < (int)m; ++i) {
    if (c[i] != d[a[i]][b[i]]) ans++;
  }
  cout << ans << endl;
  return 0;
}
