#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const long long mod = 1000000007;
const long long inf = long long(1e9);
const long long half_inf = long long(1e5);
const long long ll_inf = long long(1e9) * long long(1e9);
const long long MAX_E = 100 * 100;
long long V, E;
long long d[100][100];
long long raw[100][100];
void warshall_floyd() {
  for (long long k = 0; k < (long long)(V); k++)
    for (long long i = 0; i < (long long)(V); i++)
      for (long long j = 0; j < (long long)(V); j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
void solve() {
  warshall_floyd();
  long long ans = 0;
  for (long long i = 0; i < (long long)(V); i++) {
    for (long long j = 0; j < (long long)(V); j++) {
      if (raw[i][j] != d[i][j]) ans++;
    }
  }
  cout << ans / 2 << endl;
}
int main() {
  cin >> V >> E;
  for (long long i = 0; i < (long long)(E); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
    raw[a][b] = c;
    raw[b][a] = c;
  }
  solve();
  return 0;
}
