#include <bits/stdc++.h>
using namespace std;
void impl(){};
template <typename T, typename... TS>
void impl(T &head, TS &...tail) {
  cin >> head;
  impl(tail...);
}
int d[200][200];
int V;
void warshall_floyd() {
  int i, j, k;
  for ((k) = 0; (k) < (V); (k)++)
    for ((i) = 0; (i) < (V); (i)++)
      for ((j) = 0; (j) < (V); (j)++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
struct Edge {
  int s;
  int t;
  int c;
};
signed main(void) {
  int i, j, k;
  for ((i) = 0; (i) < (200); (i)++)
    for ((j) = 0; (j) < (200); (j)++) d[i][j] = i == j ? 0 : 1001001001;
  Edge e[200] = {};
  cin >> V;
  int M;
  impl(M);
  for ((i) = 0; (i) < (M); (i)++) {
    int a, b, c;
    impl(a, b, c);
    if (a > b) swap(a, b);
    e[i] = (Edge){a - 1, b - 1, c};
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  warshall_floyd();
  if (int i = 0) {
  } else {
    if (int j = 0) {
    } else
      (1) ? 0 : printf("%4d,", d[i][j]);
    puts("");
  }
  int count = M;
  for ((k) = 0; (k) < (M); (k)++) {
    bool flg = false;
    for (i = 0; i < V; i++) {
      for (j = 0; j < V; j++) {
        if (d[i][e[k].s] + e[k].c + d[e[k].t][j] == d[i][j]) flg = true;
      }
    }
    count -= flg;
  }
  cout << (count) << endl;
  return 0;
}
