#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int V, M;
int d[100][100], f[100][100];
void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  cin >> V >> M;
  int A, B, C, ans = 0;
  for (int i = 0; i < M; i++) {
    cin >> A >> B >> C;
    A--;
    B--;
    d[A][B] = d[B][A] = f[A][B] = f[B][A] = C;
  }
  warshall_floyd();
  for (int i = 0; i < V; i++)
    for (int j = i + 1; j < V; j++)
      if (f[i][j] > d[i][j]) ans++;
  cout << ans << endl;
  return 0;
}
