#include <bits/stdc++.h>
using namespace std;
bool ans[1010] = {};
vector<pair<int, pair<int, int> > > edge[1010];
int n, m;
void dijkstra(int start) {
  priority_queue<pair<int, pair<int, int> > > que;
  que.push(make_pair(0, make_pair(start, -1)));
  bool used[101] = {};
  while (que.size()) {
    int nowC = -que.top().first;
    int now = que.top().second.first;
    int nowEdgeNum = que.top().second.second;
    que.pop();
    if (used[now]) continue;
    used[now] = true;
    if (nowEdgeNum != -1) ans[nowEdgeNum] = true;
    for (int i = 0; i < edge[now].size(); i++) {
      int to = edge[now][i].first;
      int toC = nowC + edge[now][i].second.first;
      int toEdgeNum = edge[now][i].second.second;
      que.push(make_pair(-toC, make_pair(to, toEdgeNum)));
    }
  }
}
int main() {
  cin >> n >> m;
  int a, b, c;
  for (long long i = (0); i < ((m)); i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a].push_back(make_pair(b, make_pair(c, i)));
    edge[b].push_back(make_pair(a, make_pair(c, i)));
  }
  for (long long i = (0); i < ((n)); i++) {
    dijkstra(i);
  }
  int how = 0;
  for (long long i = (0); i < ((m)); i++) {
    if (ans[i] == false) how++;
  }
  cout << how << endl;
  return 0;
}
