#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void warshall_floyd(int n, vector<vector<int> > &g) {
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<vector<int> > g(n, vector<int>(n));
  map<pair<int, int>, int> mp;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a][b] = c;
    g[b][a] = c;
    mp[make_pair(a, b)] = c;
  }
  warshall_floyd(n, g);
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (g[itr->first.first][itr->first.second] != itr->second) ++ans;
  }
  cout << ans << '\n';
  return 0;
}
