#include <bits/stdc++.h>
using namespace std;
int g[111][111];
int is[111][111];
bool ok[111][111];
int n, m;
int a, b, c;
vector<pair<int, int> > edge;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = c;
    g[b][a] = c;
    is[a][b] = is[b][a] = c;
    edge.push_back(make_pair(a, b));
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    }
  }
  for (int k = 0; k < edge.size(); k++) {
    int a = edge[k].first, b = edge[k].second;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (g[i][a] + is[a][b] == g[i][b]) ok[a][b] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++)
      if (is[i][j] && !ok[i][j]) ans++;
  }
  cout << ans << endl;
  return 0;
}
