#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T>
inline void priv(vector<T> a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ((i == a.size() - 1) ? "\n" : " ");
  }
}
inline void fastio() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
long long gcd(long long a, long long b) {
  int c = max(a, b);
  int d = min(a, b);
  return c == 0 || d == 0 ? c : gcd(c % d, d);
}
long long lcm(long long a, long long b) {
  return a == 0 || b == 0 ? 0 : a * b / gcd(a, b);
}
long long modfact(long long a) {
  long long b = 1;
  for (int i = 2; i <= a; i++) b = b * i % 1000000007LL;
  return b;
}
long long modpow(long long a, long long n) {
  long long b = 1;
  while (n > 0) {
    if (n & 1) b = b * a % 1000000007LL;
    a = a * a % 1000000007LL;
    n >>= 1;
  }
  return b;
}
long long modcomb(long long n, long long k) {
  long long b = 1;
  k = min(n - k, k);
  for (int i = n; i >= n - k + 1; i--) b = b * i % 1000000007LL;
  return b * modpow(modfact(k), 1000000007LL - 2) % 1000000007LL;
}
int N, M;
int A[1000], B[1000], C[1000];
int dist[100][100];
int main() {
  fastio();
  long long N, M;
  int inf = 1 << 30;
  cin >> N >> M;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) dist[i][j] = i == j ? 0 : inf;
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
    dist[A[i]][B[i]] = min(dist[A[i]][B[i]], C[i]);
    dist[B[i]][A[i]] = min(dist[B[i]][A[i]], C[i]);
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
  int ans = M;
  for (int i = 0; i < M; i++) {
    for (int s = 0; s < N; s++) {
      if (dist[s][A[i]] + C[i] == dist[s][B[i]] ||
          dist[s][B[i]] + C[i] == dist[s][A[i]]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
