#include <bits/stdc++.h>
using namespace std;
const int nax = 1e5 + 5;
const int INF = 1e9 + 5;
int main() {
  int n, m;
  int cnt = 0;
  cin >> n >> m;
  pair<int, int> dist[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i != j) {
        dist[i][j] = {INF, 1};
      } else {
        dist[i][j] = {0, 0};
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a][b] = {c, 0};
    dist[b][a] = {c, 0};
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (dist[i][j].first > dist[i][k].first + dist[k][j].first) {
          dist[i][j].first = dist[i][k].first + dist[k][j].first;
          dist[j][i].first = dist[i][j].first;
          if (dist[i][j].second == 0) {
            cnt++;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
