#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
using namespace std;
const int INF = 2000000;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  bitset<1000> bs;
  vector<vector<pair<int, bitset<1000> > > > mat(
      n, vector<pair<int, bitset<1000> > >(n, make_pair(INF, bs)));
  for (int i = 0, i_len = (n); i < i_len; ++i) {
    mat[i][i] = make_pair(0, bs);
  }
  for (int i = 0, i_len = (m); i < i_len; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    mat[a][b] = mat[b][a] = make_pair(c, bitset<1000>(1uL << i));
  }
  for (int k = 0, k_len = (n); k < k_len; ++k) {
    for (int i = 0, i_len = (n); i < i_len; ++i) {
      for (int j = 0, j_len = (n); j < j_len; ++j) {
        if (mat[i][k].first == INF || mat[k][j].first == INF) continue;
        if (chmax(mat[i][j].first, mat[i][k].first + mat[k][j].first)) {
          mat[i][j].second = mat[i][k].second | mat[k][j].second;
        }
      }
    }
  }
  for (int i = 0, i_len = (n); i < i_len; ++i) {
    for (int j = 0, j_len = (n); j < j_len; ++j) {
      bs |= mat[i][j].second;
    }
  }
  cout << m - bs.count() << "\n";
  return 0;
}
