#include <bits/stdc++.h>
using namespace std;
const long long LINF = 8931145141919364364, LMOD = 998244353;
const int INF = 1e9;
vector<vector<int>> d;
void Warshall_Floyd(int n) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (j == k) d[j][k] = 0;
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  d = vector<vector<int>>(n, vector<int>(n, INF));
  pair<pair<int, int>, int> edge[m];
  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    from--, to--;
    edge[i] = {{from, to}, cost};
    d[from][to] = cost;
    d[to][from] = cost;
  }
  Warshall_Floyd(n);
  bool used[m];
  for (int k = 0; k < m; k++) {
    int from = edge[k].first.first, to = edge[k].first.second,
        cost = edge[k].second;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        if (d[i][from] + cost + d[to][j] == d[i][j]) {
          used[k] = 1;
        }
      }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++)
    if (!used[i]) cnt++;
  cout << cnt << endl;
  return 0;
}
