#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<pair<int, int>, int> mp;
  int e[n][n], g[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i == j)
        g[i][j] = e[i][j] = 0;
      else
        g[i][j] = e[i][j] = 1 << 25;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    mp[pair<int, int>(a, b)] = mp[pair<int, int>(b, a)] = i;
    g[a][b] = g[b][a] = e[a][b] = e[b][a] = c;
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) e[i][j] = min(e[i][k] + e[k][j], e[i][j]);
  bool used[m];
  memset(used, 0, sizeof(used));
  for (int s = 0; s < n; s++) {
    for (int t = 0; t < n; t++) {
      bool vi[n];
      memset(vi, 0, sizeof(vi));
      queue<int> q;
      q.push(s);
      while (!q.empty()) {
        int cur = q.front();
        q.pop();
        if (vi[cur]) continue;
        vi[cur] = 1;
        for (int i = 0; i < n; i++) {
          if (i != cur && g[cur][i] + e[i][t] == e[s][t]) {
            q.push(i);
            used[mp[pair<int, int>(i, cur)]] = 1;
          }
        }
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) ans -= used[i];
  cout << ans << endl;
  return 0;
}
