#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
int main() {
  ll n, m, w[100][100];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        w[i][j] = 0;
      } else {
        w[i][j] = INF;
      }
    }
  }
  vector<pair<ll, pair<ll, ll>>> e;
  for (int i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    w[a][b] = c;
    w[b][a] = c;
    e.push_back({a, {b, c}});
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto x : e) {
    ll a = x.first, b = x.second.first, c = x.second.second;
    bool flag = false;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (w[i][a] + c + w[b][j] == w[i][j]) {
          flag = true;
        }
      }
    }
    if (!flag) {
      ans++;
    }
  }
  cout << ans << endl;
}
