#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long keta(long long n) {
  string s = to_string(n);
  long long num = s.size();
  return num;
}
const long long INF = 1LL << 60;
const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  int G[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j)
        G[i][j] = 0;
      else
        G[i][j] = G[j][i] = 1e9;
    }
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G[a[i]][b[i]] = G[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) chmin(G[i][j], G[i][k] + G[k][j]);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    bool ok = true;
    for (int s = 0; s < n; s++)
      if (G[s][b[i]] == G[s][a[i]] + c[i]) ok = false;
    if (ok) ans++;
  }
  cout << ans << endl;
}
