#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
long long MOD = 1000000007;
const int MAX_V = 100;
struct edge {
  int to;
  long long cost;
  bool used;
};
int V;
vector<edge> G[MAX_V];
long long d[MAX_V];
void dijkstra(int s) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      que;
  fill(d, d + V, INFll);
  d[s] = 0;
  que.push(pair<long long, int>(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 (int i = 0; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        e.used = true;
        que.push(pair<long long, int>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    G[a[i]].push_back(edge{b[i], long long(c[i]), false});
    G[b[i]].push_back(edge{a[i], long long(c[i]), false});
  }
  V = n;
  for (int i = 0; i < n; i++) {
    dijkstra(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      if (!G[i][j].used) ans++;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
