#include <bits/stdc++.h>
using namespace std;
int n, m;
int e[100][100], d[100], c[100];
bool used[100][100];
void dijkstra_init() {
  for (int i = 0; i < n; i++) {
    d[i] = (1 << 28);
    c[i] = 0;
  }
  return;
}
void dijkstra(int s) {
  bool flg[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      flg[i][j] = false;
    }
  }
  d[s] = 0;
  c[s] = 1;
  while (1) {
    int minv = (1 << 28), u = -1;
    for (int i = 0; i < n; i++) {
      if (minv > d[i] && c[i] != 2) {
        u = i;
        minv = d[i];
      }
    }
    if (u == -1) break;
    c[u] = 2;
    for (int v = 0; v < n; v++) {
      if (c[v] != 2 && e[u][v] != (1 << 28)) {
        if (d[v] > d[u] + e[u][v]) {
          d[v] = d[u] + e[u][v];
          flg[s][v] = flg[v][s] = false;
          flg[s][u] = flg[u][s] = true;
          flg[u][v] = flg[v][u] = true;
          c[v] = 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      used[i][j] |= flg[i][j];
    }
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      e[i][j] = (1 << 28);
      used[i][j] = false;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    e[a][b] = e[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    dijkstra_init();
    dijkstra(i);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (used[i][j]) cnt++;
    }
  }
  cout << m - cnt << endl;
  return 0;
}
