#include <bits/stdc++.h>
using namespace std;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long LINF = numeric_limits<long long>::max() / 3;
struct Double {
  double d;
  explicit Double(double x) : d(x) {}
};
ostream& operator<<(ostream& os, const Double x) {
  os << fixed << setprecision(20) << x.d;
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  os << "[";
  for (const auto& v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
  os << "{";
  for (T v : st) os << v << ",";
  os << "}";
  return os;
}
template <typename T, typename U>
inline void chmax(T& x, U y) {
  if (y > x) x = y;
}
template <typename T, typename U>
inline void chmin(T& x, U y) {
  if (y < x) x = y;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
constexpr double eps = 1e-10;
constexpr long long mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
long long N;
long long M;
long long g[101][101];
long long aa[101], bb[101], cc[101];
int main() {
  for (int i = 0; i < 101; i++)
    for (int j = 0; j < 101; j++) g[i][j] = LINF;
  for (int i = 0; i < 101; i++) g[i][i] = 0;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = g[b][a] = c;
    aa[i] = a;
    bb[i] = b;
    cc[i] = c;
  }
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  long long cnt = 0;
  for (int i = 0; i < M; i++) {
    long long a = aa[i];
    long long b = bb[i];
    long long c = cc[i];
    if (g[a][b] < c) cnt++;
  }
  cout << cnt << endl;
}
