#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, k, n, m, ans = 0;
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > vec[n];
  bool flg[m];
  for (i = 0; i < m; ++i) flg[i] = true;
  int c, t;
  pair<int, int> a[m];
  for (i = 0; i < m; ++i) {
    scanf("%d%d%d", &a[i].first, &a[i].second, &c);
    a[i].first--, a[i].second--;
    vec[a[i].first].push_back(make_pair(a[i].second, c));
    vec[a[i].second].push_back(make_pair(a[i].first, c));
    if (a[i].first > a[i].second)
      t = a[i].first, a[i].first = a[i].second, a[i].second = t;
  }
  sort(a, a + m);
  for (k = 0; k < n; ++k) {
    pair<int, int> dis[n];
    int now = k;
    for (i = 0; i < n; ++i) dis[i].first = 1e9;
    dis[k].first = 0;
    set<pair<int, int> > s;
    for (i = 0; i < n; ++i)
      if (i != k) s.insert(make_pair(1e9, i));
    while (!s.empty()) {
      for (i = 0; i < vec[now].size(); ++i)
        if (dis[vec[now][i].first].first >
            dis[now].first + vec[now][i].second) {
          s.erase(s.find(
              make_pair(dis[vec[now][i].first].first, vec[now][i].first)));
          dis[vec[now][i].first].first = dis[now].first + vec[now][i].second,
          dis[vec[now][i].first].second = now;
          s.insert(make_pair(dis[vec[now][i].first].first, vec[now][i].first));
        }
      now = (*s.begin()).second;
      s.erase(s.begin());
    }
    for (i = 0; i < n; ++i)
      if (i != k) {
        now = i;
        while (now != k) {
          int ta = now, tb = dis[now].second;
          if (ta > tb) t = ta, ta = tb, tb = t;
          pair<int, int> p = make_pair(ta, tb);
          flg[lower_bound(a, a + n, p) - a] = false;
          now = dis[now].second;
        }
      }
  }
  for (i = 0; i < m; ++i)
    if (flg[i]) ++ans;
  printf("%d", ans);
  return 0;
}
