#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
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;
}
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<vector<ll> > gragh(n, vector<ll>(n, INF));
  vector<vector<ll> > reg(n, vector<ll>(3));
  for (int i = 0; i < (int)(n); i++) {
    gragh[i][i] = 0;
  }
  for (int i = 0; i < (int)(m); i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    gragh[a][b] = c;
    gragh[b][a] = c;
    reg[i][0] = a;
    reg[i][1] = b;
    reg[i][2] = 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(gragh[i][j], gragh[i][k] + gragh[k][j]);
      }
    }
  }
  ll cnt = 0;
  for (int i = 0; i < (int)(m); i++) {
    if (gragh[reg[i][0]][reg[i][1]] < reg[i][2]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
