#include <bits/stdc++.h>
using namespace std;
const int INF = 10000500;
const int MAXN = 1e5 + 9;
int dd[105][105];
int init[105][105];
int n, m;
bool ok[100500];
map<pair<int, int>, int> mp;
vector<int> path;
void input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      dd[i][j] = INF;
      init[i][j] = INF;
      if (i == j) dd[i][j] = init[i][j] = 0;
    }
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    dd[u][v] = dd[v][u] = w;
    init[u][v] = init[v][u] = 1;
    mp[{u, v}] = i;
    mp[{v, u}] = i;
  }
}
void solve() {
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (dd[i][j] > dd[i][k] + dd[k][j]) dd[i][j] = dd[i][k] + dd[k][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int u = 0; u < n; u++)
        for (int v = 0; v < n; v++) {
          if (u == v || init[u][v] == INF) continue;
          if (dd[i][j] == dd[i][u] + init[v][u] + dd[v][j]) ok[mp[{u, v}]] = 1;
          if (dd[i][j] == dd[i][v] + init[v][u] + dd[u][j]) ok[mp[{u, v}]] = 1;
        }
    }
  int ans = 0;
  for (int i = 0; i < m; i++)
    if (!ok[i]) ans++;
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  input();
  solve();
  return 0;
}
