#include <bits/stdc++.h>
using namespace std;
int n, m, c, a[1005][1005];
bool v[1005][1005];
int main() {
  int i, j, k, t1, t2, t3;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      a[i][j] = 1e9;
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &t1, &t2, &t3);
    a[t1][t2] = a[t2][t1] = t3;
    v[t1][t2] = v[t2][t1] = 1;
  }
  for (k = 1; k <= n; k++) {
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        if (i != j && a[i][j] > a[i][k] + a[k][j]) {
          a[i][j] = a[j][i] = a[i][k] + a[k][j];
          if (v[i][j]) c++;
        }
      }
    }
  }
  cout << c << endl;
  return 0;
}
