#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long LLINF = 1LL << 60;
const int INF = 1 << 30;
const int MOD = 1000000007;
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int MAX_V = 110;
const int MAX_E = 1100;
int N, M;
int a[MAX_E], b[MAX_E], c[MAX_E];
int dist[MAX_V][MAX_V];
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (long long i = 0, i_len = (N); i < i_len; ++i) {
    for (long long j = 0, j_len = (N); j < j_len; ++j) {
      dist[i][j] = INF;
    }
    dist[i][i] = 0;
  }
  for (long long i = 0, i_len = (M); i < i_len; ++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];
  }
  for (long long k = 0, k_len = (N); k < k_len; ++k)
    for (long long i = 0, i_len = (N); i < i_len; ++i)
      for (long long j = 0, j_len = (N); j < j_len; ++j)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  int ans = 0;
  for (long long i = 0, i_len = (M); i < i_len; ++i)
    if (c[i] > dist[a[i]][b[i]]) ++ans;
  cout << ans << endl;
}
