#include <bits/stdc++.h>
using namespace std;
template <typename T>
void fill_all(T& arr, const T& v) {
  arr = v;
}
template <typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
  for (auto& i : arr) {
    fill_all(i, v);
  }
}
long long comb[50 + 1][50 + 1];
static void calc_comb() {
  for (uint32_t i = 0; i <= 50; i++) {
    for (uint32_t j = 0; j <= i; j++) {
      if ((j == 0) || (i == j)) {
        comb[i][j] = 1;
      } else {
        comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      }
    }
  }
}
vector<vector<long long int>> way(2001), money(2001);
long long int maxa = 0, moto = 0;
long long int d[2001][2001];
queue<long long int> q;
long long int bitmax = 0;
int main() {
  long long int n, m;
  cin >> n >> m;
  fill_all(d, (long long int)931931114518101);
  vector<tuple<long long int, long long int, long long int>> t;
  for (long long int i = (0); i < (n); ++i) {
    d[i][i] = 0;
  }
  for (long long int i = (0); i < (m); ++i) {
    long long int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    if (a > b) {
      swap(a, b);
    }
    d[a][b] = c;
    d[b][a] = c;
    tuple<long long int, long long int, long long int> tt = make_tuple(a, b, c);
    t.push_back(tt);
  }
  for (long long int i = (0); i < (n); ++i) {
    for (long long int j = (0); j < (n); ++j) {
      for (long long int k = (0); k < (n); ++k) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long int cnt = 0;
  for (long long int i = (0); i < (t.size()); ++i) {
    tuple<long long int, long long int, long long int> tt = t.back();
    t.pop_back();
    if (get<2>(tt) > d[get<0>(tt)][get<1>(tt)]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
