#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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
using vec = std::vector<T>;
template <class T>
void print(const T &x) {
  cout << x << "\n";
}
const long long MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
set<long long> group[120][120];
long long cost[120][120] = {INF};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  long long N, M;
  cin >> N >> M;
  for (long long i = 0; i < M; i++) {
    long long p, q, r;
    cin >> p >> q >> r;
    p--, q--;
    cost[p][q] = r;
    cost[q][p] = r;
    group[p][q].insert(i);
    group[q][p].insert(i);
  }
  for (long long i = 0; i < N; i++) {
    cost[i][i] = 0;
  }
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        bool flg = chmin(cost[i][j], cost[i][k] + cost[k][j]);
        if (flg) {
          set<long long> tmp(group[i][k]);
          tmp.insert(group[k][j].begin(), group[k][j].end());
          group[i][j] = tmp;
        }
      }
    }
  }
  set<long long> ans;
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      if (i != j) ans.insert(group[i][j].begin(), group[i][j].end());
    }
  }
  print(M - ans.size());
}
