#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, a, b, c;
  set<pair<int, int>> e;
  cin >> N >> M;
  vector<vector<long long>> d(N, vector<long long>(N, INT_MAX));
  while (M--) {
    cin >> a >> b >> c;
    d[--a][--b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (d[i][j] < INT_MAX && d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          e.insert(make_pair(i, j));
          e.erase(make_pair(j, i));
          e.erase(make_pair(i, k));
          e.erase(make_pair(k, i));
          e.erase(make_pair(j, k));
          e.erase(make_pair(k, j));
        }
      }
    }
  }
  cout << e.size();
}
