#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
constexpr long long INF = 1LL << 62;
bool used[101][101];
void warshall_floyd(int n, vector<vector<ll> > &g) {
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) {
        if (chmin(g[i][j], g[i][k] + g[k][j])) {
          used[i][j] = false;
          used[i][k] = true;
          used[k][j] = true;
        }
      }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<vector<ll> > g(n, vector<ll>(n, INF));
  ll as[1010], bs[1010];
  for (int i = 0; i < m; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a][b] = c;
    g[b][a] = c;
    as[i] = a;
    bs[i] = b;
  }
  for (int i = 0; i < n; ++i) g[i][i] = 0;
  warshall_floyd(n, g);
  ll ans = 0;
  for (int i = 0; i < m; ++i) {
    if (!used[as[i]][bs[i]] && !used[bs[i]][as[i]]) ++ans;
  }
  cout << ans << '\n';
  return 0;
}
