#include <bits/stdc++.h>
using namespace std;
int graph[101][101];
int dist[101][101];
int pre[101][101];
int V;
void floydWarshall() {
  int i, j, k;
  for (i = 0; i < V; i++)
    for (j = 0; j < V; j++) dist[i][j] = graph[i][j];
  for (k = 0; k < V; k++) {
    for (i = 0; i < V; i++) {
      for (j = 0; j < V; j++) {
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          pre[i][j] = k;
        }
      }
    }
  }
}
set<pair<int, int> > s;
void f() {
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (i == j) continue;
      int curr = pre[i][j];
      int curr2 = j;
      while (curr2 != curr) {
        if (curr > curr2) swap(curr, curr2);
        s.insert(make_pair(curr, curr2));
        curr2 = curr;
        curr = pre[i][curr2];
      }
    }
  }
}
int main(void) {
  int n, m;
  cin >> n >> m;
  memset(graph, 0, sizeof(graph));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  V = n;
  floydWarshall();
  f();
  cout << (m - (s.size()));
  return 0;
}
