#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void WF(int n, vector<vector<long long int>> &d) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(M);
  vector<vector<long long int>> G(N, vector<long long int>(N, 0));
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G[a[i]][b[i]] = c[i];
    G[b[i]][a[i]] = c[i];
  }
  WF(N, G);
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (G[a[i]][b[i]] < c[i]) ans++;
  }
  cout << ans << endl;
}
