#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> list(n, vector<int>(n, INF)), cost(n, vector<int>(n, INF));
  for (int i = 0; i < m; i++) {
    int s, e, c;
    cin >> s >> e >> c; s--, e--;
    list[s][e] = c;
    list[e][s] = c;
    cost[s][e] = c;
    cost[e][s] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (list[i][j] != INF && cost[i][j] != list[i][j]) {
        cnt++;
      }
    }
  }

  cout << cnt / 2 << endl;
  return 0;
}
