#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int dist[100][100], copy[100][100];
  cin >> n >> m;
  memset(dist, 1e9, sizeof(dist));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = dist[b][a] = c;
    copy[a][b] = copy[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (dist[i][j] < copy[i][j]) sum++;
    }
  }
  cout << sum / 2 << endl;
  return 0;
}
