#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vvl = vector<vl>;
constexpr int MOD = 1000000007;
using long long = long long;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int d[100][100];
int V;
void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  int M;
  cin >> V >> M;
  vector<int> a(M), b(M);
  vector<int> c(M);
  for (long long i = 0; i < (long long)M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i] - 1][b[i] - 1] = c[i];
    d[b[i] - 1][a[i] - 1] = c[i];
  }
  warshall_floyd();
  int cnt = 0;
  for (long long i = 0; i < (long long)M; i++) {
    if (c[i] != d[a[i] - 1][b[i] - 1]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
