#include <bits/stdc++.h>
using namespace std;
void reconstruct(int, int, vector<int>&);
const int INF = 1e9;
int adj[101][101] =
    {
        0,
},
    check[101][101] =
        {
            0,
},
    via[101][10];
vector<int> path;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) adj[i][j] = INF;
  for (int i = 1; i <= n; i++) adj[i][i] = 0;
  while (m--) {
    int u, v, cost;
    scanf("%d %d %d", &u, &v, &cost);
    adj[u][v] = adj[v][u] = cost;
    check[u][v] = check[v][u] = 1;
  }
  memset(via, -1, sizeof(via));
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (adj[i][j] > adj[i][k] + adj[k][j]) {
          via[i][j] = k;
          adj[i][j] = adj[i][k] + adj[k][j];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      reconstruct(i, j, path);
      for (int i = 0; i < path.size() - 1; i++) {
        check[path[i]][path[i + 1]] = check[path[i + 1]][path[i]] = 0;
      }
      path.clear();
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (check[i][j] == 1) ans++;
    }
  }
  printf("%d\n", ans / 2);
  return 0;
}
void reconstruct(int u, int v, vector<int>& path) {
  if (via[u][v] == -1) {
    path.push_back(u);
    if (u != v) path.push_back(v);
  } else {
    int w = via[u][v];
    reconstruct(u, w, path);
    path.pop_back();
    reconstruct(w, v, path);
  }
}
