#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[104];
bool mark[104][104];
int par[105];
int dis[104];
void s_p(int st, int ed) {
  par[st] = -1;
  for (int i = 0; i < 103; i++) dis[i] = 1000000;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      q;
  q.push({0, st});
  dis[st] = 0;
  while (!q.empty()) {
    int top = q.top().second;
    int cost = q.top().first;
    q.pop();
    if (top == ed) break;
    for (int i = 0; i < adj[top].size(); i++) {
      int chi = adj[top][i].second;
      int cst = adj[top][i].first;
      if (cost + cst <= dis[chi]) {
        dis[chi] = cost + cst;
        q.push({dis[chi], chi});
        par[chi] = top;
      }
    }
  }
}
bool vis[104];
void path(int ed) {
  while (par[ed] != -1) {
    int x = par[ed];
    mark[x][ed] = 1;
    mark[ed][x] = 1;
    ed = par[ed];
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back({w, v});
    adj[v].push_back({w, u});
  }
  int cnt = 0;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n; j++) {
      memset(vis, 0, sizeof vis);
      s_p(i, j);
      path(j);
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (mark[i][j]) cnt++;
    }
  }
  cout << m - cnt << endl;
}
