#include <bits/stdc++.h>
using namespace std;
int N, M;
int d[110][110];
bool e[110][110];
int INF = 2147483647;
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      e[i][j] = false;
      if (i == j) {
        d[i][j] = 0;
        e[i][j] = true;
      } else
        d[i][j] = INF;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    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++) {
        if (d[i][j] < d[i][k] + d[k][j]) {
          e[i][j] = true;
        } else if (d[i][j] > d[i][k] + d[k][j]) {
          e[i][k] = true;
          e[k][j] = true;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (e[i][j] == false) cnt++;
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}
