#include <bits/stdc++.h>
using namespace std;
int static fast = []() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();
int main() {
  int n, m, a, b, c;
  cin >> n >> m;
  vector<vector<int>> edge(n, vector<int>(n, 1e6));
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a][b] = edge[b][a] = c;
  }
  for (int i = 0; i < n; i++) edge[i][i] = 0;
  vector<vector<int>> e2 = edge;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (i == k || j == k) continue;
        if (e2[i][k] + e2[k][j] < e2[i][j]) e2[i][j] = e2[i][k] + e2[k][j];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (edge[i][j] != 1e6 && edge[i][j] != e2[i][j]) ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}
