#include <bits/stdc++.h>
using namespace std;
int inf_int = 2e9;
long long inf_ll = 1e18;
const double pi = 3.1415926535898;
bool debug = 0;
const int MAXN = 200;
int mod = 1e9 + 9;
vector<pair<int, int> > g[MAXN];
vector<int> ind[MAXN];
char ans[MAXN];
int d[MAXN];
void solve() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].push_back({b, c});
    ind[a].push_back(i);
    g[b].push_back({a, c});
    ind[b].push_back(i);
  }
  for (int st = 1; st <= n; ++st) {
    set<pair<int, int> > s;
    fill(d, d + n + 2, inf_int);
    d[st] = 0;
    s.insert({0, st});
    while (!s.empty()) {
      int v = s.begin()->second;
      s.erase(s.begin());
      for (int i = 0; i < g[v].size(); ++i) {
        int to = g[v][i].first;
        int len = g[v][i].second;
        if (d[to] > d[v] + len) {
          s.erase({d[to], to});
          d[to] = d[v] + len;
          s.insert({d[to], to});
        }
      }
    }
    for (int v = 1; v <= n; ++v) {
      for (int i = 0; i < g[v].size(); ++i) {
        int to = g[v][i].first, len = g[v][i].second, in = ind[v][i];
        if (d[v] + len == d[to]) {
          ans[in] = 1;
        }
      }
    }
  }
  int res = 0;
  for (int i = 1; i <= m; ++i) {
    if (!ans[i]) res++;
  }
  cout << res << "\n";
}
int main() {
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int t = 1;
  while (t--) solve();
  return 0;
}
