#include <bits/stdc++.h>
using namespace std;
using Matrix = vector<vector<int>>;
const int INF = 1 << 28;
Matrix d;
void warshall_floyd(int n) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}
int main() {
  int N, M;
  cin >> N >> M;
  d = Matrix(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++) d[i][i] = 0;
  int C[M];
  for (int i = 0; i < M; i++) {
    int from, to, cost;
    cin >> from >> to >> C[i];
    d[--from][--to] = C[i];
  }
  warshall_floyd(N);
  int ans = M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (d[i][j] == C[i]) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
