#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> d;
void warshall_floyd(int n) {
  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]);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  d = vector<vector<int>>(n, vector<int>(n, INT_MAX));
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  vector<vector<int>> graph2;
  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    from--;
    to--;
    d[from][to] = cost;
    d[to][from] = cost;
    graph2.push_back({from, to, cost});
  }
  warshall_floyd(n);
  int ans = 0;
  for (auto v : graph2) {
    if (d[v[0]][v[1]] < v[2]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
