#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const long long INFF = 1e18;
const int MAX_N = 110;
vector<pair<int, int>> G[MAX_N];
int dist[MAX_N][MAX_N];
int a[1010], b[1010], c[1010];
int main(void) {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < (M); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < (M); i++)
    G[a[i]].push_back(make_pair(b[i], c[i])),
        G[b[i]].push_back(make_pair(a[i], c[i]));
  for (int i = 0; i < (N); i++)
    for (int j = 0; j < (N); j++) dist[i][j] = INF;
  for (int i = 0; i < (N); i++) dist[i][i] = 0;
  for (int k = 0; k < (N); k++)
    for (int i = 0; i < (N); i++)
      for (int j = 0; j < (N); j++)
        dist[i][j] = dist[i][j] = (((dist[i][j]) > (dist[i][k] + dist[k][j]))
                                       ? (dist[i][k] + dist[k][j])
                                       : (dist[i][j]));
  set<pair<int, int>> second;
  for (int k = 0; k < (N); k++)
    for (int i = 0; i < (N); i++)
      for (int j = 0; j < (N); j++) {
        if (dist[i][a[k]] + c[k] + dist[b[k]][j]) {
          second.insert(make_pair(min(a[k], b[k]), min(a[k], b[k])));
        }
      }
  printf("%d\n", M - second.size());
  return 0;
}
