#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}
inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int n, m, a, b, c;
int g[101][101], d[101][101];
int main() {
  init();
  cin >> n >> m;
  memset(d, 0x3f, sizeof d);
  memset(g, 0x3f, sizeof g);
  for (int i = (0); i < (n); ++i) d[i][i] = 0;
  for (int i = (0); i < (m); ++i) {
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = g[b][a] = c;
    d[a][b] = d[b][a] = c;
  }
  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 ans = 0;
  for (int i = (0); i < (n); ++i) {
    for (int j = (i + 1); j < (n); ++j) {
      bool f = true;
      for (int k = (0); k < (n); ++k) {
        if (i != k and j != k and d[i][j] >= d[i][k] + d[k][j] and
            g[i][j] != 0x3f3f3f3f) {
          f = false;
          break;
        }
      }
      if (!f) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
