#include <bits/stdc++.h>
using namespace std;
int n, m;
long long fw[101][101];
long long fw2[101][101];
int main() {
  cin >> n >> m;
  int mm = 0;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      fw[i][j] = 1000000;
      fw2[i][j] = 0;
      if (i == j) {
        fw[i][j] = 0;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    fw[a][b] = c;
    fw[b][a] = c;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (fw[i][k] + fw[k][j] < fw[i][j] and fw[i][j] != 1000000) {
          fw[i][j] = fw[i][k] + fw[k][j];
          mm++;
        }
      }
    }
  }
  cout << mm / 2 << endl;
}
