#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > way[100010];
bool flag[100010];
int n, m;
int calc(int s, int g) {
  int cost[100010] = {};
  bool visited[100010] = {};
  priority_queue<pair<int, int> > pq;
  pq.push({0, s});
  for (int i = 0; i < m; i++) {
    visited[i] = false;
  }
  while (pq.size()) {
    pair<int, int> p = pq.top();
    pq.pop();
    int now = p.second;
    int now_cost = p.first;
    if (visited[now]) break;
    visited[now] = true;
    cost[now] = -now_cost;
    for (int i = 0; i < way[now].size(); i++) {
      pq.push({now_cost - way[now][i].first.second, way[now][i].first.first});
    }
  }
  pq.push({cost[g], g});
  for (int i = 0; i < n; i++) {
    visited[i] = false;
  }
  while (pq.size()) {
    pair<int, int> p = pq.top();
    pq.pop();
    int now = p.second;
    int now_cost = p.first;
    if (visited[now]) break;
    visited[now] = true;
    cost[now] = -now_cost;
    for (int i = 0; i < way[now].size(); i++) {
      int next = way[now][i].first.first;
      int id = way[now][i].second;
      if (now_cost - way[now][i].first.second == cost[next]) {
        flag[id] = true;
        pq.push({now_cost - way[now][i].first.second, next});
      }
    }
  }
  return 0;
}
int main() {
  int a, b, c;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    a--;
    b--;
    way[a].push_back({{b, c}, i});
    way[b].push_back({{a, c}, i});
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      calc(i, j);
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (flag[i] == false) ans++;
  }
  cout << ans << endl;
  return 0;
}
