#include <bits/stdc++.h>
using namespace std;
const int inf = 1e8;
struct edge {
  int to, cost;
};
int N, M;
vector<edge> G[111];
int d[111];
int flag[111][111];
int ans;
void dijkstra(int s) {
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      que;
  for (int i = (1); i < (N + 1); ++i) d[i] = inf;
  d[s] = 0;
  que.push(pair<int, pair<int, int> >(0, pair<int, int>(s, s)));
  while (!que.empty()) {
    pair<int, pair<int, int> > pp = que.top();
    que.pop();
    int v = pp.second.second;
    if (d[v] <= pp.first) continue;
    int u = pp.second.first;
    if (!flag[u][v] && !flag[v][u] && v != s && u != s) {
      ans--;
      flag[u][v] = true;
    }
    for (auto &e : G[v]) {
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pair<int, pair<int, int> >(d[e.to], pair<int, int>(v, e.to)));
      }
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = (0); i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    edge e1 = {b, c};
    edge e2 = {a, c};
    G[a].push_back(e1);
    G[b].push_back(e2);
  }
  for (int i = (0); i < (N + 1); ++i)
    for (int j = (0); j < (N + 1); ++j) flag[i][j] = false;
  ans = M;
  for (int i = (1); i < (N + 1); ++i) {
    dijkstra(i);
  }
  cout << ans << endl;
  return 0;
}
