#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int d[100][100];
int V;
bool used[100][100];
void warshall_floyd() {
  for (int k = (int)0; k < (int)V; k++)
    for (int i = (int)0; i < (int)V; i++)
      for (int j = (int)0; j < (int)V; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M;
  cin >> V >> M;
  for (int i = (int)0; i < (int)V; i++)
    for (int j = (int)0; j < (int)V; j++) d[i][j] = 1e9;
  int a[V], b[V], c[V];
  for (int i = (int)0; i < (int)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];
  }
  warshall_floyd();
  int rsl = M;
  for (int i = (int)0; i < (int)M; i++) {
    bool flag = false;
    for (int j = (int)0; j < (int)V; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) flag = true;
    }
    if (flag) rsl--;
  }
  cout << rsl << endl;
}
