#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long>> V[110];
long long d[110];
int pre[110], C[110][110];
void dijkstra(int s, vector<pair<int, long long>> G[]) {
  priority_queue<pair<int, long long>, vector<pair<int, long long>>,
                 greater<pair<int, long long>>>
      que;
  for (int i = 0; i < 110; i++) d[i] = 1100000000000000;
  d[s] = 0;
  que.push(pair<int, long long>(0, s));
  while (!que.empty()) {
    pair<int, long long> p = que.top();
    que.pop();
    long long v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); i++) {
      pair<int, long long> e = G[v][i];
      if (d[e.first] > d[v] + e.second) {
        pre[e.first] = v;
        d[e.first] = d[v] + e.second;
        que.push(pair<int, long long>(d[e.first], e.first));
      }
    }
  }
}
int main() {
  int N, M, a, b, c;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    V[a].push_back(pair<int, long long>(b, c));
    V[b].push_back(pair<int, long long>(a, c));
  }
  for (int i = 0; i < N; i++) {
    dijkstra(i, V);
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      C[pre[j]][j]++;
      C[j][pre[j]]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < (int)V[i].size(); j++) {
      if (C[i][V[i][j].first] == 0) ans++;
    }
  }
  cout << ans / 2 << endl;
}
