#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> G[106];
int d[106][106];
vector<int> q;
int v[106];
int main() {
  int n, m;
  int a, b, c;
  int i, j, k;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n; j++) {
      d[i][j] = 100100100;
    }
  }
  int head = 0;
  int tail = 0;
  for (i = 1; i <= n; i++) {
    head = 0;
    tail = 0;
    d[i][i] = 0;
    q.clear();
    for (j = 0; j <= n; j++) v[j] = 0;
    q.push_back(i);
    tail++;
    v[i] = 1;
    while (head != tail) {
      int u = q[head++];
      for (j = 0; j < G[u].size(); j++) {
        int t;
        t = G[u][j].first;
        int r;
        r = G[u][j].second;
        if (v[t] != 1) {
          q.push_back(t);
          tail++;
        }
        if (d[i][t] > d[i][u] + r) {
          d[i][t] = d[t][i] = d[i][u] + r;
        }
      }
      v[u] = 1;
    }
  }
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j) continue;
      for (k = 0; k < G[i].size(); k++) {
        if (G[i][k].first == j) {
          if (G[i][k].second > d[i][j]) cnt++;
        }
      }
    }
  }
  printf("%d\n", cnt / 2);
}
