#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
bool cand[1005];
int n;
int dist[100];
vector<pair<int, int>> graf[105];
struct edge {
  int a, b, c;
};
vector<edge> edges;
void dijkstra(int root) {
  set<pair<int, int>> q;
  for (int i = 1; i <= n; i++) dist[i] = INF;
  dist[root] = 0;
  q.insert({0, root});
  while (!q.empty()) {
    pair<int, int> par = *q.begin();
    q.erase(q.begin());
    int v = par.second;
    for (auto p : graf[v]) {
      if (dist[p.first] > dist[v] + p.second) {
        q.erase({dist[p.first], p.first});
        dist[p.first] = dist[v] + p.second;
        q.insert({dist[p.first], p.first});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  int m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edges.push_back({a, b, c});
    graf[a].push_back({b, c});
    graf[b].push_back({a, c});
  }
  for (int i = 1; i <= n; i++) {
    dijkstra(i);
    for (int j = 0; j < m; j++) {
      if (!cand[j] && edges[j].c == abs(dist[edges[j].a] - dist[edges[j].b])) {
        cand[j] = 1;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    cnt += 1 - cand[i];
  }
  cout << cnt;
  return 0;
}
