#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int u, v, c;
} edge;
int main() {
  int V, M;
  scanf("%d %d\n", &V, &M);
  vector<vector<int> > g(V, vector<int>(V, (INT_MAX / 3)));
  vector<edge> es;
  for (int i = (int)(0); i < (int)(M); i++) {
    int a, b, cost;
    scanf("%d %d %d\n", &a, &b, &cost);
    g[a - 1][b - 1] = cost;
    g[b - 1][a - 1] = cost;
    edge e;
    e.u = a - 1;
    e.v = b - 1;
    e.c = cost;
    es.push_back(e);
  }
  for (int i = (int)(0); i < (int)(V); i++) {
    g[i][i] = 0;
  }
  for (int i = (int)(0); i < (int)(V); i++) {
    for (int j = (int)(0); j < (int)(V); j++) {
      for (int k = (int)(0); k < (int)(V); k++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto i = es.begin(); i != es.end(); i++) {
    if (g[i->u][i->v] < i->c) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
