#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int>> graph, flag;
vector<int> color, d, p;
void Dijsktra(int s) {
  color.resize(N + 1), d.resize(N + 1, 1000000000), p.resize(N + 1, -1);
  d[s] = 0;
  while (true) {
    int min_cost = 1000000000, u;
    for (int i = 1; i <= N; i++)
      if (color[i] != 2 && d[i] < min_cost) min_cost = d[i], u = i;
    if (min_cost == 1000000000) break;
    color[u] = 2;
    for (int v = 1; v <= N; v++) {
      if (color[v] != 2 && graph[u][v] != -1) {
        if (d[u] + graph[u][v] < d[v]) {
          d[v] = d[u] + graph[u][v], p[v] = u, color[v] = 1;
          flag[u][v]++, flag[v][u]++;
        }
      }
    }
  }
}
int main() {
  cin >> N >> M;
  graph.resize(N + 1, vector<int>(N + 1, -1)),
      flag.resize(N + 1, vector<int>(N + 1, -1));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    graph[a][b] = c, graph[b][a] = c, flag[a][b] = 0, flag[b][a] = 0;
  }
  for (int i = 1; i <= N; i++) Dijsktra(i);
  int ans = 0;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (flag[i][j] == 0) ans++;
  ans /= 2;
  cout << ans << endl;
}
