#include <bits/stdc++.h>
using namespace std;
const int Nmax = 100;
const int M = 10000;
int d[Nmax + 10][Nmax + 10];
int graph[Nmax + 10][Nmax + 10];
int a[Nmax + 10];
int b[Nmax + 10];
int c[Nmax + 10];
int n, m;
int t[Nmax + 10];
bool remain(bool *s) {
  bool f = false;
  for (int i = 1; i <= n; i++) {
    if (s[i] == false) f = true;
  }
  return f;
}
int select_min(bool *s, int *t) {
  int ans = M;
  int index = -1;
  for (int i = 1; i <= n; i++) {
    if (t[i] < ans && !s[i]) {
      ans = t[i];
      index = i;
    }
  }
  return index;
}
int *dijkstra(int tmp) {
  bool s[Nmax + 10] = {};
  s[tmp] = true;
  for (int i = 1; i <= n; i++) {
    t[i] = graph[tmp][i];
  }
  while (remain(s)) {
    int u = select_min(s, t);
    if (u == -1) break;
    s[u] = true;
    for (int x = 1; x <= n; x++) {
      int k = t[u] + graph[u][x];
      if (k < t[x]) t[x] = k;
    }
  }
  return t;
}
int main() {
  for (int i = 0; i < Nmax + 10; i++) {
    for (int j = 0; j < Nmax + 10; j++) {
      d[i][j] = M;
      if (i != j)
        graph[i][j] = M;
      else
        graph[i][j] = 0;
    }
  }
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= m; i++) {
    graph[a[i]][b[i]] = c[i];
    graph[b[i]][a[i]] = c[i];
  }
  for (int i = 1; i <= n; i++) {
    int *tmp = dijkstra(i);
    for (int j = 1; j <= n; j++) {
      d[i][j] = tmp[j];
    }
  }
  int cnt = 0;
  for (int j = 1; j <= m; j++) {
    bool f = false;
    for (int i = 1; i <= n; i++) {
      if (d[i][a[j]] + c[i] == d[i][b[j]]) f = true;
    }
    if (!f) ++cnt;
  }
  cout << cnt << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
    }
  }
}
