#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<pair<int, int> > > V;
int USED[1010][1010];
void dijkstra(int start) {
  priority_queue<pair<int, int> > PQ;
  int color[1010];
  int d[1010];
  int bef[1010];
  for (int i = 0; i < N; i++) {
    d[i] = 1000000000;
    color[i] = 0;
    bef[i] = -1;
  }
  d[start] = 0;
  color[start] = 1;
  bef[start] = start;
  PQ.push(make_pair(0, start));
  while (!PQ.empty()) {
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color[u] = 2;
    if (d[u] < f.first * (-1)) continue;
    for (int j = 0; j < V[u].size(); j++) {
      int v = V[u][j].first;
      if (color[v] == 2) continue;
      if (d[v] > d[u] + V[u][j].second) {
        d[v] = d[u] + V[u][j].second;
        if (bef[v] == -1) {
          USED[v][u] = USED[u][v] = 1;
        } else {
          USED[v][bef[v]] = 0;
          USED[bef[v]][v] = 0;
          USED[v][u] = 1;
          USED[u][v] = 1;
        }
        bef[v] = u;
        color[v] = 1;
        PQ.push(make_pair(d[v] * -1, v));
      }
    }
  }
}
int main(void) {
  cin >> N >> M;
  int a, b, c;
  V.resize(N);
  for (int i = 0; i < 1010; i++)
    for (int j = 0; j < 1010; j++) USED[i][j] = -1;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    V[a].push_back(make_pair(b, c));
    V[b].push_back(make_pair(a, c));
    USED[a][b] = 0;
    USED[b][a] = 0;
  }
  for (int i = 0; i < N; i++) dijkstra(i);
  int zero = 0;
  int minus = 0;
  int one = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (USED[i][j] == 1)
        one++;
      else if (USED[i][j] == 0)
        zero++;
      else
        minus++;
    }
  }
  cout << (zero) / 2 << endl;
}
