#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  int n, m, u[1003] = {}, v[1003] = {}, w[1003] = {}, z = 0, d[102][102] = {};
  vector<pair<int, int>> g[102] = {};
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> u[i] >> v[i] >> w[i], g[u[i]].push_back({v[i], w[i]}),
        g[v[i]].push_back({u[i], w[i]});
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) d[i][j] = 890328;
    d[i][i] = 0;
    bool b[102] = {};
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        q;
    q.push({0, i});
    while (!q.empty()) {
      int x = q.top().second;
      q.pop();
      if (b[x]) continue;
      b[x] = 1;
      for (pair<int, int> j : g[x]) {
        if (d[i][j.first] > d[i][x] + j.second) {
          d[i][j.first] = d[i][x] + j.second;
          q.push({d[i][j.first], j.first});
        }
      }
    }
  }
  for (int t = 0; t < m; t++) {
    int e[102][102] = {};
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) e[i][j] = 890328;
      e[i][i] = 0;
      bool b[102] = {};
      priority_queue<pair<int, int>, vector<pair<int, int>>,
                     greater<pair<int, int>>>
          q;
      q.push({0, i});
      while (!q.empty()) {
        int x = q.top().second;
        q.pop();
        if (b[x]) continue;
        b[x] = 1;
        for (pair<int, int> j : g[x]) {
          if (x == u[t] && j.first == v[t]) continue;
          if (x == v[t] && j.first == u[t]) continue;
          if (e[i][j.first] > e[i][x] + j.second) {
            e[i][j.first] = e[i][x] + j.second;
            q.push({e[i][j.first], j.first});
          }
        }
      }
    }
    bool y = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (d[i][j] != e[i][j]) y = 1;
    if (!y) z++;
  }
  cout << z;
}
