#include <bits/stdc++.h>
using namespace std;
const int inf = 1e+9;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> U(n, vector<int>(n, 0));
  int cost[n][n];
  queue<pair<int, int>> que;
  for (int i = 0; i < (int)m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    cost[a][b] = cost[b][a] = c;
    que.push({a, b});
  }
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)n; j++) {
      if (i == j) continue;
      int d[n], prev[n];
      bool used[n];
      fill(d, d + n, inf);
      fill(used, used + n, false);
      fill(prev, prev + n, -1);
      d[i] = 0;
      while (true) {
        int v = -1;
        for (int u = 0; u < (int)n; u++)
          if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        if (v == -1) break;
        used[v] = true;
        for (int u = 0; u < (int)n; u++) {
          if (d[u] > d[v] + cost[v][u]) {
            d[u] = d[v] + cost[v][u];
            prev[u] = v;
          }
        }
      }
      vector<int> path;
      int t = j;
      for (; t != -1; t = prev[t]) path.push_back(t);
      for (int k = 0; k < (int)path.size() - 1; k++) U[path[k]][path[k + 1]]++;
    }
  int res = 0;
  for (int i = 0; i < (int)n; i++) {
    auto p = que.front();
    que.pop();
    int a = p.first, b = p.second;
    if (U[a][b] == 0) res++;
  }
  cout << res << endl;
}
