#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MAX = 101;
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  static int d[MAX][MAX];
  static int adj[MAX][MAX];
  stack<pair<int, int> > S;
  set<pair<int, int> > adjE;
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      if (i != j) {
        d[i][j] = INF;
        adj[i][j] = INF;
      } else {
        d[i][j] = 0;
        adj[i][j] = 0;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    d[a][b] = c;
    d[b][a] = c;
    adj[a][b] = c;
    adj[b][a] = c;
    S.push(make_pair(a, b));
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i + 1][j + 1] =
            min(d[i + 1][j + 1], d[i + 1][k + 1] + d[k + 1][j + 1]);
      }
    }
  }
  while (!S.empty()) {
    pair<int, int> ab = S.top();
    S.pop();
    int a = ab.first;
    int b = ab.second;
    for (int s = 1; s <= N - 1; s++) {
      for (int t = s + 1; t <= N; t++) {
        if (d[s][t] == d[s][a] + adj[a][b] + d[b][t]) {
          adjE.insert(ab);
        }
      }
    }
  }
  printf("%d\n", M - adjE.size());
}
