#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 100;
int V;
vector<pair<int, long long>> G[MAX_V];
long long d[MAX_V];
bool check[105][105];
bool edge[105][105];
void dijkstra(int s) {
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      que;
  for (int i = 0; i < (V); ++i) d[i] = 1e18;
  d[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    pair<long long, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (auto e : G[v]) {
      if (d[e.first] > d[v] + e.second) {
        d[e.first] = d[v] + e.second;
        que.emplace(d[e.first], e.first);
        if (v > e.first) swap(v, e.first);
        check[v][e.first] = true;
      }
    }
  }
}
int main() {
  int m;
  cin >> V >> m;
  for (int i = 0; i < (m); ++i) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
    if (a > b) swap(a, b);
    edge[a][b] = true;
  }
  int ans = 0;
  for (int i = 0; i < (V); ++i) dijkstra(i);
  for (int i = 0; i < (V); ++i)
    for (int j = 0; j < (i); ++j) {
      if (edge[i][j] = true && check[j][i] == false) ans++;
    }
  cout << ans << endl;
  return 0;
}
