#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
void Main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> graph(N, vector<int>(N, INF));
  map<pair<int, int>, int> edges;
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    graph[a][b] = c;
    graph[b][a] = c;
    if (a > b) {
      swap(a, b);
    }
    edges.insert(make_pair(make_pair(a, b), c));
  }
  vector<vector<int>> minDist = graph;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        minDist[i][j] = min(minDist[i][j], minDist[i][k] + minDist[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto edge : edges) {
    int a = edge.first.first;
    int b = edge.first.second;
    int c = edge.second;
    if (minDist[a][b] < c) {
      bool notused = true;
      for (int v = 0; v < N; ++v) {
        if (v == a || v == b) {
          continue;
        }
        if (c < minDist[a][v] + minDist[v][b]) {
          notused = false;
        }
        if (!notused) {
          break;
        }
      }
      if (notused) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
