#include <bits/stdc++.h>
const int INF = 1000000000;
using namespace std;
const int MAX_V = 105;
void init(int m[MAX_V][MAX_V]) {
  for (int i = 0; i < (MAX_V); i++)
    for (int j = 0; j < (MAX_V); j++) m[i][j] = INF;
  for (int i = 0; i < (MAX_V); i++) m[i][i] = 0;
}
void warshallFloyd(int m[MAX_V][MAX_V], int n) {
  for (int k = 0; k < (n); k++) {
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (n); j++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int g[MAX_V][MAX_V];
  int ng[MAX_V][MAX_V];
  init(g);
  init(ng);
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = c;
    g[b][a] = c;
    ng[a][b] = c;
    ng[b][a] = c;
  }
  warshallFloyd(g, n);
  int path[MAX_V] = {0};
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      path[i] = max(path[i], g[i][j]);
    }
  }
  int cnt = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      if (ng[i][j] == INF) break;
      if (g[i][j] != ng[i][j]) {
        cnt++;
      }
    }
  }
  cout << cnt / 2 << endl;
}
