#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
template <class T, size_t S>
using arr = array<T, S>;
template <class T1, class T2>
using pr = pair<T1, T2>;
using ll = long long;
using ull = unsigned long long;
template <class T>
void chmax(T& dest, const T& target) {
  dest = max(dest, target);
}
template <class T>
void chmin(T& dest, const T& with) {
  dest = min(dest, with);
}
int main() {
  int N, M;
  cin >> N >> M;
  vec<vec<int>> dist(N, vec<int>(N, 1145141919));
  vec<vec<int>> edge(N, vec<int>(N, -1));
  for (decltype(M) i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a][b] = c;
    edge[a][b] = c;
  }
  for (decltype(N) i = 0; i < N; i++) {
    dist[i][i] = 0;
  }
  for (decltype(N) i = 0; i < N; i++) {
    for (decltype(N) j = 0; j < N; j++) {
      for (decltype(N) k = 0; k < N; k++) {
        chmin(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  int cnt = 0;
  for (decltype(N) i = 0; i < N; i++) {
    for (decltype(i) j = 0; j < i; j++) {
      if (edge[i][j] != -1 && dist[i][j] < edge[i][j]) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
