#include <bits/stdc++.h>
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e2 + 1;
int N, M;
int e[MAX_N][MAX_N];
int re[MAX_N][MAX_N];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(M);
  for (int i = (int)0; i < (int)M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    e[a[i]][b[i]] = e[b[i]][a[i]] = c[i];
  }
  int ans = 0;
  for (int k = (int)0; k < (int)N; ++k) {
    for (int i = (int)0; i < (int)N; ++i) {
      for (int j = (int)0; j < (int)N; ++j) {
        if (e[i][j] > e[i][k] + e[k][j]) ans++;
        e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
      }
    }
  }
  cout << (ans / 2) << endl;
  return 0;
}
