#include <bits/stdc++.h>
using namespace std;
string s;
int n, m;
vector<pair<int, int> > G[1000];
bool ok[100][100];
int dist[100];
const int INF = 100000000;
void daiku(int from, int to) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      bfs;
  bfs.push(make_pair(0, from));
  for (int i = 0; i < n; i++) dist[i] = INF;
  while (!bfs.empty()) {
    pair<int, int> t = bfs.top();
    bfs.pop();
    int next = t.second, cost = t.first;
    if (dist[next] != INF) continue;
    dist[next] = cost;
    for (int i = 0; i < G[next].size(); i++) {
      bfs.push(make_pair(cost + G[next][i].second, G[next][i].first));
    }
  }
  int now = to;
  for (int co = 0; co < n; co++) {
    if (now == from) break;
    for (int i = 0; i < G[now].size(); i++) {
      int next = G[now][i].first, cost = G[now][i].second;
      if (dist[next] + cost == dist[now]) {
        ok[now][next] = ok[next][now] = 1;
        now = next;
      }
    }
  }
}
int main() {
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) daiku(i, j);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < G[i].size(); j++)
      if (!ok[i][G[i][j].first]) ans++;
  }
  if (ans > 0) ans /= 2;
  cout << ans << endl;
}
