#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int adj[n][n];
  set<pair<int, int>> edges[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      adj[i][j] = 20000;
    }
  int dist[n][n];
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    adj[a - 1][b - 1] = c;
    adj[b - 1][a - 1] = c;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        dist[i][j] = 0;
      else if (adj[i][j] <= 1000) {
        dist[i][j] = adj[i][j];
        edges[i][j].insert({i, j});
      } else
        dist[i][j] = 20000;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (i == j || j == k || k == i) continue;
        int d = dist[i][j] + dist[i][k];
        if (d < dist[j][k]) {
          dist[j][k] = d;
          edges[j][k].clear();
          edges[j][k].insert({i, j});
          edges[j][k].insert({i, k});
        } else if (d == dist[j][k]) {
          edges[j][k].insert({i, j});
          edges[j][k].insert({i, k});
        }
      }
    }
  }
  set<pair<int, int>> count;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (auto x : edges[i][j]) {
        if (count.find({x.second, x.first}) == count.end()) count.insert(x);
      }
    }
  }
  cout << m - count.size() << "\n";
}
