#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int adj[100][100] = {};
  int usd[100][100] = {};
  pair<int, int> edge[1000];
  int dist[100];
  for (int i = 0; i < (int)(m); i++) {
    dist[i] = 1 << 8;
    for (int k = 0; k < (int)(m); k++) {
      adj[i][k] = 0;
      usd[i][k] = 0;
    }
  }
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[i].first = a - 1;
    edge[i].second = b - 1;
    adj[a - 1][b - 1] = c;
    adj[b - 1][a - 1] = c;
  }
  dist[0] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int i = 0; i < n; i++) {
      if (cur == i) continue;
      if (adj[cur][i] > 0) {
        if (dist[i] > adj[cur][i] + dist[cur]) {
          q.push(i);
          dist[i] = adj[cur][i] + dist[cur];
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    int x = edge[i].first;
    int y = edge[i].second;
    if (adj[x][y] > abs(dist[x] - dist[y])) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
