#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long int INF = 2e9;
long long int dist[105][105];
void warchall_floyd(int N) {
  for (int k = 0; k < (N); ++k)
    for (int i = 0; i < (N); ++i) {
      if (dist[i][k] == INF) continue;
      for (int j = 0; j < (N); ++j) {
        if (dist[k][j] == INF) continue;
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) dist[i][j] = INF;
    dist[i][i] = 0;
  }
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < (m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  warchall_floyd(n);
  int ans = 0;
  for (int i = 0; i < (m); ++i) {
    if (dist[a[i]][b[i]] == c[i]) continue;
    if (dist[b[i]][a[i]] == c[i]) continue;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
