#include <bits/stdc++.h>
using namespace std;
int cost[105][105];
int check[105][105];
int V, E;
int s, t, d;
void floyd_warshall() {
  for (int k = 1; k <= V; k++) {
    for (int i = 1; i <= V; i++) {
      for (int j = 1; j <= V; j++) {
        if (cost[i][k] < INT_MAX && cost[k][j] < INT_MAX) {
          if (cost[i][k] + cost[k][j] < cost[i][j]) {
            cost[i][j] = cost[i][k] + cost[k][j];
            check[i][k] = 1;
            check[k][j] = 1;
          }
        }
      }
    }
  }
}
int main() {
  cin >> V >> E;
  for (int i = 1; i <= V; i++) {
    for (int j = 1; j <= V; j++) {
      if (i == j)
        cost[i][j] = 0;
      else
        cost[i][j] = INT_MAX;
    }
  }
  for (int i = 1; i <= E; i++) {
    cin >> s >> t >> d;
    cost[s][t] = d;
    cost[t][s] = d;
  }
  floyd_warshall();
  int ok = 0;
  for (int i = 1; i <= V; i++) {
    for (int j = 1; j <= V; j++) {
      if (check[i][j] == 1) {
        ok++;
        check[i][j] = 0;
      }
    }
  }
  cout << (2 * E - ok) / 2 << endl;
  return 0;
}
