#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e6;
const long long inf = 1e9 + 5;
const long long mod = 1e9 + 7;
long long g[102][102];
long long f[102][102];
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = (0); i < (n); ++i) g[i][i] = 0;
  for (long long i = (0); i < (n); ++i) f[i][i] = 0;
  for (long long i = (0); i < (m); ++i) {
    long long x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    g[x][y] = c;
    g[y][x] = c;
  }
  for (long long k = (0); k < (n); ++k) {
    for (long long i = (0); i < (n); ++i) {
      for (long long j = (0); j < (n); ++j) {
        if (g[i][j] > g[i][k] + g[k][j]) {
          f[i][j] = 1;
          f[i][k] = 0;
          f[k][j] = 0;
        }
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  long long cnt = 0;
  for (long long i = (0); i < (n); ++i) {
    for (long long j = (i); j < (n); ++j) {
      if (f[i][j] == 1) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
