#include <bits/stdc++.h>
using namespace std;
int V, E;
bool ex_edge[1000][1000];
int d[1000][1000];
int used[1000][1000];
void warshall_floyd() {
  for (int a = 0; a < V; a++) {
    for (int b = 0; b < V; b++) {
      for (int c = 0; c < V; c++) {
        if (d[b][a] + d[a][c] < d[b][c]) {
          used[b][c]--;
          used[a][c]++;
          d[b][c] = d[b][a] + d[a][c];
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> V >> E;
  fill(d[0], d[V], INT_MAX / 2);
  for (int v = 0; v < V; v++) {
    d[v][v] = 0;
  }
  for (int i = 0; i < E; i++) {
    int v, w, cost;
    cin >> v >> w >> cost;
    v--;
    w--;
    d[v][w] = cost;
    d[w][v] = cost;
    used[v][w] = 1;
    ex_edge[v][w] = true;
  }
  warshall_floyd();
  int ans = 0;
  for (int v = 0; v < E; v++) {
    for (int w = 0; w < E; w++) {
      if (ex_edge[v][w] && used[v][w] <= 0) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
