#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const int MAX_V = 101;
int d[MAX_V][MAX_V];
int V, E;
vector<int> a, b;
map<pair<int, int>, bool> mp;
void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        if (d[i][k] == INF || d[k][j] == INF) {
          continue;
        }
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          mp[make_pair(i, j)] = false;
          mp[make_pair(i, k)] = true;
          mp[make_pair(k, j)] = true;
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> V >> E;
  a.resize(E);
  b.resize(E);
  for (int i = 0; i < E; i++) {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    ai--;
    bi--;
    a[i] = ai;
    b[i] = bi;
    d[ai][bi] = ci;
    d[bi][ai] = ci;
    mp[make_pair(ai, bi)] = true;
    mp[make_pair(bi, ai)] = true;
  }
  warshall_floyd();
  int ans = 0;
  for (int i = 0; i < E; i++) {
    if (!mp[make_pair(a[i], b[i])]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
