#include <bits/stdc++.h>
using namespace std;
long long dis[110][110];
long long a[110], b[110], c[110];
int main() {
  long long n, m, inf = 1e15;
  for (int i = 0; i < (110); i++)
    for (int j = i + 1; j < 110; j++) dis[i][j] = dis[j][i] = inf;
  cin >> n >> m;
  pair<pair<long long, long long>, long long> p[1010];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    dis[a[i]][b[i]] = dis[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++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  long long ans = m;
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (n); j++) {
      if (dis[j][a[i]] + c[i] == dis[j][b[i]]) {
        ans--;
        break;
      }
    }
  cout << ans << endl;
  return 0;
}
