#include <bits/stdc++.h>
using namespace std;
int memo[105][105] = {0};
vector<pair<int, int>> edge[105];
int n, m;
int solve();
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    edge[a].push_back(make_pair(b, c));
    memo[a][b] = memo[b][a] = c;
  }
  cout << solve() << endl;
  return 0;
}
int solve() {
  int ans = 0;
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        memo[i][j] = min(memo[i][j], memo[i][k] + memo[k][j]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < edge[i].size(); ++j)
      if (memo[i][edge[i][j].first] < edge[i][j].second) ++ans;
  return ans;
}
