#include <bits/stdc++.h>
using namespace std;
int n, m;
int adjmat[111][111];
int parent[111][111];
bool path[111][111];
int a, b, c;
int ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      adjmat[i][j] = 1000000000;
      parent[i][j] = i;
      path[i][j] = false;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    adjmat[a][b] = c;
    adjmat[b][a] = c;
    path[a][b] = true;
    path[b][a] = true;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (adjmat[i][k] + adjmat[k][j] < adjmat[i][j]) {
          adjmat[i][j] = adjmat[i][k] + adjmat[k][j];
          parent[i][j] = parent[k][j];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      path[i][parent[i][j]] = false;
      path[parent[i][j]][i] = false;
      path[j][parent[i][j]] = false;
      path[parent[i][j]][j] = false;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (path[i][j]) ans++;
    }
  }
  cout << ans / 2 << endl;
}
