#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;
template <typename T>
vector<int> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
  const T INF = numeric_limits<T>::max();
  int n = G.size();
  using P = pair<T, int>;
  vector<T> ds(n, INF);
  vector<int> pre(n, -1);
  priority_queue<P, vector<P>, greater<P>> pq;
  ds[s] = 0;
  pq.emplace(ds[s], s);
  while (!pq.empty()) {
    P p = pq.top();
    pq.pop();
    int v = p.second;
    if (ds[v] < p.first) {
      continue;
    }
    for (auto &e : G[v]) {
      int u = e.first;
      T cost = e.second;
      if (ds[u] > ds[v] + cost) {
        ds[u] = ds[v] + cost;
        pre[u] = v;
        pq.emplace(ds[u], u);
      }
    }
  }
  return pre;
}
int ansG[104][104];
int main() {
  int N, M;
  if (scanf("%d %d", &N, &M) == 1) {
    return 1;
  }
  using P = pair<int, long long>;
  vector<vector<P>> G(N);
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (N); j++) {
      ansG[i][j] = -1;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    if (scanf("%d %d %d", &a, &b, &c) == 1) {
      return 1;
    }
    a--;
    b--;
    G[a].emplace_back(b, c);
    G[b].emplace_back(a, c);
    ansG[a][b] = 1;
    ansG[b][a] = 1;
  }
  for (int i = 0; i < (N); i++) {
    auto pre = dijkstra(i, G);
    for (int j = 0; j < (N); j++) {
      ansG[pre[j]][j] = -1;
      ansG[j][pre[j]] = -1;
    }
  }
  int ans = 0;
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (N); j++) {
      if (ansG[i][j] != -1) {
        ans++;
      }
    }
  }
  printf("%d\n", ans / 2);
  return 0;
}
