#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> t(n, vector<int>(n, 1e+9)), used(n, vector<int>(n, 0));
  queue<pair<int, int>> que;
  for (int i = 0; i < (int)m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    t[a][b] = c;
    t[b][a] = c;
    que.push({a, b});
  }
  for (int k = 0; k < (int)n; k++)
    for (int i = 0; i < (int)n; i++)
      for (int j = 0; j < (int)n; j++) {
        if (t[i][k] == 1e+9 || t[k][j] == 1e+9) continue;
        if (t[i][j] > t[i][k] + t[k][j]) {
          used[i][k]++;
          used[k][i]++;
          used[k][j]++;
          used[j][k]++;
          t[i][j] = t[i][k] + t[k][j];
        }
      }
  int res = 0;
  for (int i = 0; i < (int)m; i++) {
    auto pa = que.front();
    que.pop();
    int a = pa.first, b = pa.second;
    if (used[a][b] == 0) res++;
  }
  cout << res << endl;
}
