#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::vector<int> > dist(n, std::vector<int>(n));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) {
      { dist[i][j] = INF; }
    }
  for (int i = 0; i < (int)(n); i++) dist[i][i] = 0;
  std::vector<int> a(n), b(n), c(n);
  for (int i = 0; i < (int)(m); i++) {
    int aa, bb, cc;
    std::cin >> aa >> bb >> cc;
    aa--;
    bb--;
    dist[aa][bb] = cc;
    dist[bb][aa] = cc;
    a[i] = aa;
    b[i] = bb;
    c[i] = cc;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
  int counter = 0;
  for (int i = 0; i < (int)(m); i++)
    if (c[i] > dist[a[i]][b[i]]) counter++;
  std::cout << counter << std::endl;
}
