#include <bits/stdc++.h>
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
const int INFTY = numeric_limits<int>::max();
vector<vector<int>> d;
void warshall_floyd(int V) {
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  d = vector<vector<int>>(n, vector<int>(n, INFTY / 3));
  for (int i = 0; i < n; ++i) d[i][i] = 0;
  vector<int> from(m), to(m), cost(m);
  for (int i = 0; i < m; ++i) {
    cin >> from[i] >> to[i] >> cost[i];
    --from[i];
    --to[i];
    d[from[i]][to[i]] = cost[i];
    d[to[i]][from[i]] = cost[i];
  }
  warshall_floyd(n);
  for (int i = (int)0; i < (int)n; ++i)
    for (int j = (int)0; j < (int)n; ++j) cout << d[i][j] << endl;
  int ans = 0;
  for (int i = (int)0; i < (int)m; ++i) {
    bool judge = false;
    for (int s = (int)0; s < (int)n; ++s) {
      for (int t = (int)0; t < (int)n; ++t) {
        if (d[s][from[i]] + cost[i] + d[to[i]][t] == d[s][t]) judge = true;
      }
    }
    if (!judge) ++ans;
  }
  cout << ans << endl;
  return 0;
}
