#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 100100;
const int MOD = 1000000007;
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";
struct edge {
  int to;
  int cost;
};
int V;
vector<edge> G[1000];
int d[1000];
void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d + V, 1e+9);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P 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(P(d[e.to], e.to));
      }
    }
  }
}
int main() {
  cin >> V;
  int E;
  cin >> E;
  vector<vector<bool>> che(V, vector<bool>(V, true));
  for (int i = 0; i < E; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge e = {b, c};
    edge s = {a, c};
    G[a].push_back(e);
    G[b].push_back(s);
  }
  dijkstra(0);
  int ans = 0;
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      if (i == j) continue;
      edge e = G[i][j];
      if (d[i] + e.cost == d[j]) ans++;
    }
  }
  cout << ans / 2 << endl;
}
