#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const int MAX_V = 101;
int d[MAX_V][MAX_V];
int V, E;
int ans;
void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        if (d[i][k] == INF || d[k][j] == INF) {
          continue;
        }
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          ans++;
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    ai--;
    bi--;
    d[ai][bi] = ci;
    d[bi][ai] = ci;
  }
  warshall_floyd();
  cout << ans / 2 << endl;
  return 0;
}
