#include <bits/stdc++.h>
using namespace std;
int G[105][105], J[105][105];
int N, M;
priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>,
               greater<tuple<int, int, int>>>
    Q, Qs;
vector<int> Ret(105, 0), Rets(105, 0);
void dijk(int s, int g) {
  Ret = Rets;
  Q = Qs;
  Q.push(make_tuple(0, s, -1));
  int a, b, c;
  while (!Q.empty()) {
    tie(a, b, c) = Q.top();
    Q.pop();
    if (Ret[b]) continue;
    Ret[b] = c;
    if (b == g) break;
    for (int i = 1; i <= N; i++) {
      if (G[b][i] < 0) continue;
      Q.push(make_tuple(a + G[b][i], i, b));
    }
  }
  while (b >= 0) {
    J[b][Ret[b]] = 1;
    J[Ret[b]][b] = 1;
    b = Ret[b];
  }
}
int main() {
  int a, b, c;
  cin >> N >> M;
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 105; j++) {
      G[i][j] = -1;
      J[i][j] = 0;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    G[a][b] = c;
    G[b][a] = c;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      dijk(i, j);
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++)
    for (int j = i + 1; j <= N; j++) ans += J[i][j];
  cout << M - ans << endl;
}
