#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int n, m, a[110], b[110], c[110], g[110][110];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < (110); i++) {
    for (int j = 0; j < (110); j++) {
      g[i][j] = (1 << 30) - 1;
      if (i == j) g[i][j] = 0;
    }
  }
  for (int i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    g[a[i]][b[i]] = min(g[a[i]][b[i]], c[i]);
    g[b[i]][a[i]] = min(g[b[i]][a[i]], c[i]);
  }
  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]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < (m); i++) {
    bool flag = false;
    for (int j = 0; j < (n); j++) {
      if (g[j][a[i]] + c[i] == g[j][b[i]]) flag = true;
    }
    if (flag) ans--;
  }
  cout << ans << endl;
  return 0;
}
