#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 0;
vector<vector<pair<int, int>>> graph;
vector<vector<int>> dist;
vector<bool> seen;
void dfs(int f, int t, int v = -1, int p = -1, int d = 0) {
  if (v == -1) {
    for (int i = 0, i_len = (((int)(graph[f]).size())); i < i_len; i++) {
      for (int ii = 0, ii_len = (n); ii < ii_len; ii++) seen[i] = false;
      dfs(f, t, graph[f][i].first, f, graph[f][i].second);
    }
    return;
  }
  if (v == t) {
    dist[f][t] = min(dist[f][t], d);
    return;
  }
  if (seen[v]) {
    return;
  }
  seen[v] = true;
  for (int i = 0, i_len = (((int)(graph[v]).size())); i < i_len; i++) {
    if (graph[v][i].first == p) continue;
    dfs(f, t, graph[v][i].first, v, d + graph[v][i].second);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  graph.resize(n);
  dist.resize(n);
  seen.resize(n);
  for (int i = 0, i_len = (n); i < i_len; i++) {
    dist[i].resize(n, INT_MAX);
    dist[i][i] = 0;
  }
  for (int i = 0, i_len = (m); i < i_len; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph[a].emplace_back(b, c);
    graph[b].emplace_back(a, c);
  }
  for (int i = 0, i_len = (n); i < i_len; i++) {
    for (int ii = 0, ii_len = (n); ii < ii_len; ii++) {
      if (i == ii) {
        continue;
      }
      dfs(i, ii);
    }
  }
  for (int i = 0, i_len = (n); i < i_len; i++) {
    for (int ii = 0, ii_len = (((int)(graph[i]).size())); ii < ii_len; ii++) {
      if (dist[i][graph[i][ii].first] != graph[i][ii].second) {
        ans++;
      }
    }
  }
  cout << (ans / 2) << endl;
  return 0;
}
