#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using data = tuple<int, int, int>;
struct edge {
  int to, cost, id;
};
int edge[105][105];
int d[105][105];
int E[105];
signed main() {
  int N, M;
  cin >> N >> M;
  fill_n(E, M + 1, -1);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) d[i][j] = i == j ? 0 : 1e9;
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    E[i + 1] = c;
    d[a][b] = d[b][a] = c;
    edge[a][b] = edge[b][a] = i + 1;
  }
  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 cnt = 0;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < i; ++j) {
      if (edge[i][j]) {
        if (E[edge[i][j]] == d[i][j]) cnt++;
      }
    }
  cout << M - cnt << endl;
}
