#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
const int MAX_M = 1000;
const int INF = 1e8;
int cnt, N, M;
bool used[MAX_N];
int dist[MAX_N][MAX_N];
int cost[MAX_N][MAX_N]{};
void dijkstra(int s) {
  fill(used, used + N, false);
  dist[s][s] = 0;
  while (1) {
    int u = -1;
    for (int v = 0; v < N; v++) {
      if (!used[v] && (u == -1 || dist[s][v] < dist[s][u])) u = v;
    }
    if (u == -1) break;
    used[u] = true;
    for (int v = 0; v < N; v++) {
      dist[s][v] = min(dist[s][v], dist[s][u] + cost[u][v]);
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    cost[a][b] = cost[b][a] = c;
  }
  fill((int*)dist, (int*)(dist + N), INF);
  for (int s = 0; s < N; s++) dijkstra(s);
  cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i >= j || cost[i][j] == 0) continue;
      bool shortest = false;
      for (int s = 0; s < N; s++) {
        if (dist[s][j] == dist[s][i] + cost[i][j]) {
          shortest = true;
          continue;
        }
      }
      if (shortest) cnt++;
    }
  }
  cout << M - cnt << endl;
}
