#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;
}
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int n, m, d[11000][11000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) d[i][j] = (i == j ? 0 : 1001001001);
  for (int i = 0; i < (m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i], --b[i];
  }
  for (int i = 0; i < (m); ++i) {
    d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
    d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
  }
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
  int ans = 0;
  for (int i = 0; i < (m); ++i) {
    bool flag = false;
    for (int j = 0; j < (n); ++j) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) flag = true;
    }
    if (flag) ans++;
  }
  cout << m - ans << endl;
  return 0;
}
