#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = 1010, INF = 0x3f3f3f3f;
int n, m;
int f[N][N], g[N][N];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i == j)
        f[i][j] = 0;
      else
        f[i][j] = INF;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    f[a][b] = f[b][a] = c;
  }
  memcpy(g, f, sizeof f);
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  int res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (g[i][j] != f[i][j]) res++;
  cout << res << endl;
  return 0;
}
