#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
const double EPS = 1e-11;
int n, m;
vector<pair<int, int> > eses;
bool used[125][125];
int edge[125][125];
int dist[125];
bool visited[125];
vector<int> bef[125];
void dfs(int p, int t) {
  if (p == t) return;
  for (int to : bef[p]) {
    if (visited[to]) continue;
    visited[to] = true;
    used[p][to] = true;
    dfs(to, t);
  }
}
void dijk(int x) {
  for (int i = 0; i < (int)(n); ++i) dist[i] = 1e9;
  for (int i = 0; i < (int)(n); ++i) bef[i].clear();
  for (int i = 0; i < (int)(n); ++i) visited[i] = false;
  dist[x] = 0;
  for (int i = 0; i < (int)(n); ++i) {
    int p = 0;
    for (int j = 0; j < (int)(n); ++j) {
      if (visited[p] || (!visited[j] && dist[j] < dist[p])) p = j;
    }
    visited[p] = true;
    for (int to = 0; to < (int)(n); ++to) {
      if (visited[to]) continue;
      if (edge[p][to] > 1e9) continue;
      int w = edge[p][to];
      if (dist[p] + w <= dist[to]) {
        if (dist[p] + w < dist[to]) bef[to].clear();
        bef[to].push_back(p);
        dist[to] = dist[p] + w;
      }
    }
  }
  for (int i = 0; i < (int)(n); ++i) visited[i] = false;
  for (int i = 0; i < (int)(n); ++i) dfs(i, x);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) edge[i][j] = 3 + 1e9;
  for (int i = 0; i < (int)(m); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a;
    --b;
    edge[a][b] = edge[b][a] = c;
    eses.push_back(pair<int, int>(a, b));
  }
  for (int i = 0; i < (int)(n); ++i) dijk(i);
  int ans = m;
  for (int i = 0; i < (int)(m); ++i) {
    int a = eses[i].first, b = eses[i].second;
    if (used[a][b] || used[b][a]) ans--;
  }
  cout << ans << endl;
  return 0;
}
