#include <bits/stdc++.h>
const int INF = 2147483647;
const long long int MOD = 1000000007;
using namespace std;
struct edge {
  int to, cost;
  bool used;
};
void warshallFloyd(int n, const vector<vector<edge>> &g,
                   vector<vector<int>> &d) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i].push_back(100000000);
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto e : g[i]) {
      d[i][e.to] = e.cost;
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<edge>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back({b, c, false});
    g[b].push_back({a, c, false});
  }
  vector<vector<int>> d(n);
  warshallFloyd(n, g, d);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < g[i].size(); k++) {
        if (d[j][i] == d[j][g[i][k].to] + g[i][k].cost) {
          g[i][k].used = true;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (auto e : g[i]) {
      if (!e.used) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
}
