#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[110];
bool vis[110][110];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    Q;
int n, m;
void DKT(int x) {
  bool t[110];
  for (int i = 0; i < n; i++) t[i] = false;
  Q.push(make_pair(0, x + 100000));
  while (!Q.empty()) {
    int y = Q.top().first, z = Q.top().second, r = z / 200;
    Q.pop();
    z %= 200;
    if (t[z] == true) continue;
    if (r != 500) vis[r][z] = true, vis[z][r] = true;
    t[z] = true;
    for (int i = 0; i < v[z].size(); i++) {
      Q.push(make_pair(y + v[z][i].first, v[z][i].second + z * 200));
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    v[a].push_back(make_pair(c, b));
    v[b].push_back(make_pair(c, a));
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) vis[i][j] = 0;
  for (int i = 0; i < n; i++) DKT(i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (i < v[i][j].second) continue;
      if (vis[i][v[i][j].second] == false) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
