#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator<<(ostream& out, const array<T, N>& a) {
  out << "[";
  bool first = true;
  for (auto& v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "]";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
  out << "[";
  bool first = true;
  for (auto& v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator<<(ostream& out, const set<T, Cmp>& a) {
  out << "{";
  bool first = true;
  for (auto& v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator<<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{";
  bool first = true;
  for (auto& p : a) {
    out << (first ? "" : ", ");
    out << p.first << ":" << p.second;
    first = 0;
  }
  out << "}";
  return out;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
using ll = long long;
using P = pair<long long, long long>;
long long dist[1100][1100];
const long long INF = 1001001001;
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < (110); i++)
    for (long long j = 0; j < (110); j++) dist[i][j] = INF;
  long long a[n], b[n], c[n];
  for (long long i = 0; i < (n); i++) dist[i][i] = 0;
  for (long long i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (n); j++)
      for (long long k = 0; k < (n); k++)
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
  long long ret = 0;
  for (long long edge = 0; edge < (m); edge++) {
    bool found = false;
    for (long long i = 0; i < (n); i++)
      for (long long j = 0; j < (n); j++) {
        long long u = a[edge], v = b[edge], d = c[edge];
        if (dist[i][u] + d + dist[v][j] == dist[i][j]) {
          found = true;
          break;
        }
      }
    ret += !found;
  }
  cout << ret << endl;
  return 0;
}
