#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
struct edge {
  int to;
  int cost;
};
int V;
vector<edge> G[10000];
int d[10000];
void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    pair<int, 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;
        que.push(pair<int, int>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  int E, r;
  cin >> V >> E;
  for (int i = 0; i < (E); i++) {
    int f, t, c;
    cin >> f >> t >> c;
    f--;
    t--;
    edge e = {t, c};
    G[f].push_back(e);
  }
  long long path[V][V];
  for (int i = 0; i < (V); i++) {
    dijkstra(i);
    for (int j = 0; j < (V); j++) {
      path[i][j] = d[j];
    }
  }
  long long sum = 0;
  for (int i = 0; i < (V); i++) {
    for (int j = i + 1; j < V; j++) {
      for (int k = 0; k < (G[j].size()); k++) {
        long long p = path[i][j] + G[j][k].cost;
        if (path[i][G[j][k].to] != p) sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
