#include <bits/stdc++.h>
using namespace std;
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template <class T, class U>
void chmin(T &x, const U &y) {
  x = min<T>(x, y);
}
template <class T, class U>
void chmax(T &x, const U &y) {
  x = max<T>(x, y);
}
struct prepare_ {
  prepare_() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  }
} prepare__;
int n, m;
int a[1000], b[1000], c[1000];
int g[100][100];
int main() {
  cin >> n >> m;
  for (ll i = (0); i < (ll)(n); i += (ll)(1))
    for (ll j = (0); j < (ll)(n); j += (ll)(1)) g[i][i] = inf;
  for (ll i = (0); i < (ll)(n); i += (ll)(1)) g[i][i] = 0;
  for (ll i = (0); i < (ll)(m); i += (ll)(1)) {
    cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
    g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
  }
  for (ll k = (0); k < (ll)(n); k += (ll)(1))
    for (ll i = (0); i < (ll)(n); i += (ll)(1))
      for (ll j = (0); j < (ll)(n); j += (ll)(1))
        chmin(g[i][j], g[i][k] + g[j][k]);
  int res = 0;
  for (ll i = (0); i < (ll)(m); i += (ll)(1)) res += g[a[i]][b[i]] < c[i];
  cout << res << endl;
}
