#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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > dp(n, vector<int>(8, 1e9));
  for (int i = 0; i < (int)(n); i++) dp[i][i] = 0;
  using edge = tuple<int, int, int>;
  vector<edge> es(m);
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dp[a][b] = c;
    dp[b][a] = c;
    es[i] = tie(a, b, c);
  }
  for (int k = 0; k < (int)(n); k++)
    for (int i = 0; i < (int)(n); i++)
      for (int j = 0; j < (int)(n); j++) chmin(dp[i][j], dp[i][k] + dp[k][j]);
  int ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    tie(a, b, c) = es[i];
    if (c > dp[a][b]) ans++;
  }
  cout << ans << endl;
  return 0;
}
