#include <bits/stdc++.h>
using namespace std;
int d[104][104];
int V;
int nex[104][104];
long long path[104][104];
void warshall_floyd() {
  for (long long i = 0; i < V; i++) {
    for (long long j = 0; j < V; j++) {
      nex[i][j] = j;
    }
  }
  for (int k = 0; k < V; k++)
    for (int i = 0; i < V; i++)
      for (int j = 0; j < V; j++) {
        if (d[i][k] + d[k][j] < d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
          nex[i][j] = nex[i][k];
        }
      }
}
void print_path(int start, int goal) {
  for (int cur = start; cur != goal; cur = nex[cur][goal]) {
    path[cur][nex[cur][goal]] = 1;
    path[nex[cur][goal]][cur] = 1;
  }
}
int main(void) {
  long long n, m;
  cin >> n >> m;
  V = n;
  for (long long i = 0; i < V; i++) {
    for (long long j = 0; j < V; j++) {
      path[i][j] = -1;
    }
  }
  for (long long i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    path[a][b] = 0;
  }
  warshall_floyd();
  for (long long i = 0; i < V; i++) {
    for (long long j = 0; j < V; j++) {
      print_path(i, j);
    }
  }
  long long sum = 0;
  for (long long i = 0; i < V; i++) {
    for (long long j = 0; j < V; j++) {
      if (path[i][j] == 0) sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
