#include <bits/stdc++.h>
using namespace std;
template <typename H>
bool chmin(H& v1, const H v2) {
  if (v1 > v2) {
    v1 = v2;
    return true;
  }
  return false;
}
template <typename H>
bool chmax(H& v1, const H v2) {
  if (v1 < v2) {
    v1 = v2;
    return true;
  }
  return false;
}
template <typename H>
void read(H& head) {
  cin >> head;
}
template <typename H, typename... T>
void read(H& head, T&... tail) {
  cin >> head;
  read(tail...);
}
template <typename H>
void write(H head) {
  cout << head << '\n';
}
template <typename H, typename... T>
void write(H head, T... tail) {
  cout << head << " ";
  write(tail...);
}
template <typename... T>
void die(T... tok) {
  write(tok...);
  exit(0);
}
int dist[105][105];
int a[105], b[105], c[105];
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n, m;
  read(n, m);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) dist[i][j] = i == j ? 0 : 0x3f3f3f3f;
  for (int i = 0; i < (m); ++i) {
    read(a[i], b[i], c[i]);
    --a[i], --b[i];
    chmin(dist[a[i]][b[i]], c[i]);
    chmin(dist[b[i]][a[i]], c[i]);
  }
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j) chmin(dist[i][j], dist[i][k] + dist[k][j]);
  int g = 0;
  for (int i = 0; i < (m); ++i)
    if (c[i] > dist[a[i]][b[i]]) g++;
  write(g);
}
