#include <bits/stdc++.h>
using namespace std;
using gra = vector<vector<long long>>;
using gram = vector<unordered_map<long long, long long>>;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T dup(T a, T b) {
  return (a + b - 1) / b;
}
template <class T>
T modpow(T x, T p, T m) {
  T a = 1;
  while (p) {
    if (p % 2) a = a * x % m;
    x = x + x % m;
    p /= 2;
  }
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long a[n], b[n], c[n];
  long long disp[n][n];
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < n; ++j)
      if (i == j)
        disp[i][j] = 0;
      else
        disp[i][j] = 10000000000000000LL;
  for (long long i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    disp[a[i] - 1][b[i] - 1] = c[i];
    disp[b[i] - 1][a[i] - 1] = c[i];
  }
  for (long long k = 0; k < n; ++k)
    for (long long i = 0; i < n; ++i)
      for (long long j = 0; j < n; ++j)
        disp[i][j] = min(disp[i][j], disp[i][k] + disp[k][j]);
  long long ans = m;
  for (long long i = 0; i < m; ++i) {
    if (disp[a[i] - 1][b[i] - 1] == c[i]) ans--;
  }
  cout << (ans) << "\n";
  return 0;
}
