#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
ll ADD(ll x, ll y) { return (x + y) % MOD; }
ll SUB(ll x, ll y) { return (x - y + MOD) % MOD; }
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { return MUL(x, POW(y, MOD - 2)); }
const int MAX_V = 110;
int d[MAX_V][MAX_V];
void setCost(int d[MAX_V][MAX_V], int s, int e, int cost) {
  d[s][e] = d[e][s] = cost;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  const int V = n;
  for (int i = 0; i < (int)(V); i++) {
    for (int j = 0; j < (int)(V); j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = MOD;
    }
  }
  ll a[n], b[n], c[n];
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    setCost(d, a[i - 1], b[i - 1], c[i]);
  }
  for (int k = 0; k < (int)(V); k++) {
    for (int i = 0; i < (int)(V); i++) {
      for (int j = 0; j < (int)(V); j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    if (d[a[i]][b[i]] < c[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}
