#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7,
          around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
const long long LINF = 1e18;
const long double PI = abs(acos(-1));
int n, m, a[2010], b[2010], c[2010], li[110][110] = {};
set<int> st;
int main() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++)
      if (i != j) li[i][j] = INF;
  for (int i = (0); i < (m); i++)
    cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--, li[a[i]][b[i]] = c[i],
                                                 li[b[i]][a[i]] = c[i];
  for (int k = (0); k < (n); k++)
    for (int i = (0); i < (n); i++)
      for (int j = (0); j < (n); j++)
        li[i][j] = min(li[i][j], li[i][k] + li[k][j]);
  for (int i = (0); i < (n); i++)
    for (int j = (i + 1); j < (n); j++)
      for (int k = (0); k < (m); k++)
        if (li[i][a[k]] + c[k] + li[b[k]][j] == li[i][j]) st.insert(k);
  cout << m - st.size() << endl;
  return 0;
}
