#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int a[105][105];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] = 1e9;
  for (int i = 0; i < m; i++) {
    int t1, t2, t3;
    scanf("%d%d%d", &t1, &t2, &t3);
    a[t1][t2] = t3;
    a[t2][t1] = t3;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i][j] >= a[i][k] + a[k][j]) ans++, a[i][j] = a[i][k] + a[k][j];
      }
    }
  }
  printf("%d", ans / 2);
  return 0;
}
