#include <bits/stdc++.h>
using namespace std;
const long mod = 1e9 + 7;
const int size = 100;
const int INF = 1e9;
int N, M;
vector<int> g[size];
int length[size][size];
int d[size][size];
void dijkstra(int a) {
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < N; i++) {
    d[a][i] = INF;
    pq.push(make_pair(-d[a][i], i));
  }
  d[a][a] = 0;
  pq.push(make_pair(0, a));
  int v, temp;
  for (int i = 0; i < N; i++) {
    v = pq.top().second;
    pq.pop();
    for (int u : g[v]) {
      temp = d[a][v] + length[v][u];
      if (d[a][u] > temp) {
        d[a][u] = temp;
        pq.push(make_pair(-temp, u));
      }
    }
  }
  return;
}
int main() {
  cin >> N >> M;
  int A[M], B[M], C[M];
  int a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    length[a][b] = c;
    length[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for (int i = 0; i < N; i++) dijkstra(i);
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (C[i] > d[A[i]][B[i]]) ans++;
  }
  cout << ans << endl;
}
