#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> from(m), to(m), cost(m);
  vector<vector<int>> map(n, vector<int>(n, inf));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--, c--;
    from[i] = a;
    to[i] = b;
    cost[i] = c;
    map[a][b] = c;
    map[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (map[from[i]][to[i]] != cost[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
