#include <bits/stdc++.h>
using namespace std;
long long int pow(int x, int n) { return n == 0 ? 1 : x * pow(x, n - 1); }
int n, m, a[1000], b[1000], c[1000];
long long int d[100][100];
bool check[100][100];
int main() {
  for (int i = 0; i < (100); i++) {
    for (int j = 0; j < (100); j++) {
      d[i][j] = i == j ? 0 : 1000000000;
    }
  }
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < (n); k++) {
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (n); j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          check[i][k] = check[k][i] = true;
          check[j][k] = check[k][j] = true;
        }
      }
    }
  }
  int cnum = 0;
  for (int i = 0; i < (m); i++) {
    if (check[a[i]][b[i]]) cnum++;
  }
  cout << m - cnum << endl;
  return 0;
}
