#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int g[105][105] = {0};
  vector<pair<int, int> > e;
  for (int i = 0; i <= 104; i++)
    for (int j = 0; j <= 104; j++)
      if (i != j) g[i][j] = 1005;
  int vis[105][105] = {0};
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    e.push_back(make_pair(a, b));
    g[a][b] = w;
    g[b][a] = w;
    vis[a][b] = 1;
    vis[b][a] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      int mid = i;
      for (int k = 1; k <= n; k++) {
        if (g[i][k] + g[k][j] < g[i][j]) {
          g[i][j] = g[i][k] + g[k][j];
          vis[i][k] = 1;
          vis[k][j] = 1;
          vis[k][i] = 1;
          vis[j][k] = 1;
          vis[i][mid] = 0;
          vis[mid][j] = 0;
          vis[mid][i] = 0;
          vis[j][mid] = 0;
          mid = k;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < e.size(); i++) {
    int a = e[i].first, b = e[i].second;
    if (vis[b][a] || vis[a][b]) {
    } else
      cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
