#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1},
          dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
int G[100][100] = {{0}};
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (i == j)
        G[i][j] = 0;
      else
        G[i][j] = INF;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a][b] = G[b][a] = c;
  }
  set<pair<int, int> > s;
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j) continue;
        if (G[i][k] == INF || G[k][j] == INF || G[i][j] == INF) continue;
        if (G[i][k] + G[k][j] < G[i][j]) {
          G[i][j] = G[i][k] + G[k][j];
          if (i > j) {
            if (s.find(make_pair(i, j)) == s.end()) {
              s.insert(make_pair(i, j));
            }
          } else {
            if (s.find(make_pair(j, i)) == s.end()) {
              s.insert(make_pair(j, i));
            }
          }
        }
      }
    }
  }
  cout << s.size() << endl;
  return 0;
}
