#include <bits/stdc++.h>
using namespace std;
int N, M;
int a[101];
int b[101];
int c[101];
vector<int> G[101];
vector<int> cost[101];
int d[101][101];
int main() {
  for (int i = 0; i < (101); i++) {
    for (int j = 0; j < (101); j++) {
      d[i][j] = 100000000;
    }
    d[i][i] = 0;
  }
  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++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < (M); i++) {
    if (d[a[i]][b[i]] != c[i]) ans++;
  }
  cout << ans << endl;
  return (0);
}
