#include <bits/stdc++.h>
using namespace std;
static const int INF = (1 << 21);
int N, E[100][100], cnt[100][100];
void dijkstra(int s) {
  int minv;
  int d[100], color[100];
  for (int i = 0; i < N; i++) {
    d[i] = INF;
    color[i] = 0;
  }
  d[s] = 0;
  color[s] = 1;
  while (1) {
    minv = INF;
    int u = -1;
    for (int i = 0; i < N; i++) {
      if (minv > d[i] && color[i] != 2) {
        u = i;
        minv = d[i];
      }
    }
    if (u == -1) break;
    color[u] = 2;
    int p = -1;
    for (int v = 0; v < N; v++) {
      if (color[v] != 2 && E[u][v] != INF) {
        if (d[v] > d[u] + E[u][v]) {
          d[v] = d[u] + E[u][v];
          color[v] = 1;
          if (p != -1) cnt[u][p] = 1;
          cnt[u][v] = 0;
          p = v;
        }
      }
    }
  }
}
int main() {
  int M;
  cin >> N >> M;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) E[i][j] = INF;
  int u, v, c;
  for (int i = 0; i < M; i++) {
    cin >> u >> v >> c;
    u--;
    v--;
    E[u][v] = E[v][u] = c;
    cnt[u][v] = cnt[v][u] = 1;
  }
  for (int i = 0; i < N; i++) {
    dijkstra(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      sum += cnt[i][j];
    }
  }
  sum /= 2;
  cout << sum << endl;
}
