#include <bits/stdc++.h>
using namespace std;
const long long MOD = pow(10, 9) + 7;
long long mod(long long A, long long M) { return (A % M + M) % M; }
const long long INF = 1LL << 60;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long divCeil(long long A, long long B) { return (A + (B - 1)) / B; }
long long myctoi(char C) { return C - '0'; }
char myitoc(long long N) { return '0' + N; }
struct edge {
  long long to, cost;
  edge(long long to, long long cost) : to(to), cost(cost) {}
};
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N);
  vector<long long> A(N), B(N), C(N);
  vector<vector<long long>> d(N, vector<long long>(N, INF));
  for (long long i = 0; i < N; i++) {
    d.at(i).at(i) = 0;
  }
  for (long long i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G.at(a).push_back(edge(b, c));
    G.at(b).push_back(edge(a, c));
    A.at(i) = a, B.at(i) = b, C.at(i) = c;
    d.at(a).at(b) = c;
    d.at(b).at(a) = c;
  }
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        chmin(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    if (d.at(A.at(i)).at(B.at(i)) < C.at(i)) ans++;
  }
  cout << ans << endl;
}
