#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const int inf = 1e9;
int main() {
  cin.sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int pass[100][100];
  memset(pass, inf, sizeof(pass));
  for (int i = 0; i < (int)(N); i++) pass[i][i] = 0;
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    pass[a[i]][b[i]] = pass[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < (int)(N); k++) {
    for (int i = 0; i < (int)(N); i++) {
      for (int j = 0; j < (int)(N); j++)
        pass[i][j] = min(pass[i][j], pass[i][k] + pass[k][j]);
    }
  }
  int count = 0;
  for (int i = 0; i < (int)(M); i++) {
    for (int k = 0; k < (int)(N); k++) {
      if (pass[a[i]][k] == c[i] + pass[b[i]][k]) {
        count++;
        break;
      }
    }
  }
  cout << M - count << endl;
  return 0;
}
