#include <bits/stdc++.h>
using namespace std;
template <typename first, typename second>
ostream &operator<<(ostream &os, const pair<first, second> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const map<first, second> &v) {
  os << "[";
  typename map<first, second>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
long long adj[105][105];
long long dis[105][105];
int32_t main() {
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < 105; i++) {
    for (long long j = 0; j < 105; j++) {
      if (i == j) {
        dis[i][j] = 0;
        continue;
      }
      dis[i][j] = 1e18;
      adj[i][j] = 1e18;
    }
  }
  for (long long i = 0; i < m; i++) {
    long long A, B, C;
    cin >> A >> B >> C;
    adj[A][B] = C;
    adj[B][A] = C;
    dis[A][B] = C;
    dis[B][A] = C;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      for (long long k = 1; k <= n; k++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      if (adj[i][j] != 1e18) {
        if (adj[i][j] > dis[i][j]) {
          ans++;
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
