#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> edge(n + 1, vector<long long>(n + 1, INT_MAX));
  vector<vector<long long>> edgei;
  for (long long i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a][b] = c;
    edge[b][a] = c;
  }
  for (long long i = 0; i < (n); i++) {
    edge[i + 1][i + 1] = 0;
  }
  edgei = edge;
  for (long long k = 0; k < (n + 1); k++) {
    for (long long i = 0; i < (n + 1); i++) {
      for (long long j = 0; j < (n + 1); j++) {
        edgei[i][j] = min(edgei[i][j], edgei[i][k] + edgei[k][j]);
      }
    }
  }
  set<pair<int, int>> used;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n; j++) {
      vector<long long> d(n + 1, INT_MAX);
      vector<int> prev(n + 1, -1);
      priority_queue<pair<int, pair<int, int>>,
                     vector<pair<int, pair<int, int>>>,
                     greater<pair<int, pair<int, int>>>>
          pq;
      pq.push(make_pair(0, make_pair(-1, i)));
      while (!pq.empty()) {
        int tmpd = pq.top().first;
        int pre = pq.top().second.first;
        int node = pq.top().second.second;
        if (edgei[i][j] >= tmpd && d[node] > tmpd) {
          d[node] = tmpd;
          prev[node] = pre;
          if (node == j) {
            assert(tmpd == edgei[i][j]);
            int tmppre = prev[node];
            int count = 0;
            while (tmppre != -1) {
              used.insert(make_pair(min(tmppre, node), max(tmppre, node)));
              node = tmppre;
              tmppre = prev[tmppre];
              count++;
            }
            assert(count > 0);
          } else {
            for (int k = 1; k <= n; k++) {
              if (edge[node][k] != INT_MAX) {
                pq.push(make_pair(tmpd + edge[node][k], make_pair(node, k)));
              }
            }
          }
        }
        pq.pop();
      }
    }
  }
  assert(used.size() <= m);
  cout << m - used.size() << endl;
  return 0;
}
