#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > a(n, vector<long long>(n, 1e9));
  vector<pair<long long, long long> > ed(m), nt;
  for (int i = 0; i < m; ++i) {
    long long fr, to, w;
    cin >> fr >> to >> w;
    fr--, to--;
    ed[i] = {fr, to};
    a[fr][to] = a[to][fr] = w;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int x = 0; x < n; ++x) {
        if (a[j][x] > a[j][i] + a[i][x]) {
          nt.push_back({j, x});
          a[j][x] = a[j][i] + a[i][x];
        }
      }
  long long cnt = 0;
  for (int i = 0; i < nt.size(); ++i) {
    for (int j = 0; j < m; ++j) {
      if ((ed[j].first == nt[i].first && ed[j].second == nt[i].second) ||
          (ed[j].second == nt[i].first && ed[j].first == nt[i].second))
        cnt++;
    }
  }
  cout << cnt / 2;
}
