#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n));
  map<pair<int, int>, int> dp;
  set<pair<int, int>> s;
  for (int i = 0; i < m; ++i) {
    int x, y, w;
    cin >> x >> y >> w;
    --x;
    --y;
    g[x][y] = g[y][x] = w;
    dp[make_pair(x, y)] = w;
    dp[make_pair(y, x)] = w;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (!g[i][j]) g[i][j] = 1001;
      if (i == j) g[i][j] = 0;
    }
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  for (int i = 0; i < n - 1; ++i)
    for (int j = i + 1; j < n; ++j) {
      int t = g[i][j];
      if (t > 0 && t < 1001) {
        for (auto iter = dp.begin(); iter != dp.end(); ++iter)
          if (iter->second > t) s.insert(iter->first);
      }
    }
  cout << s.size() / 2 << endl;
  return 0;
}
