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