#include <bits/stdc++.h>
using namespace std;
int graph[101][101];
int dist[101][101];
int prevv[101][101];
int V;
int cnt[101][101], mark[101][101];
void floydWarshall() {
  int i, j, k;
  for (i = 0; i < V; i++)
    for (j = 0; j < V; j++) {
      if (!graph[i][j]) continue;
      dist[i][j] = graph[i][j];
      mark[i][j] = 1;
      cnt[i][j]++;
      prevv[i][j] = i;
    }
  for (k = 0; k < V; k++) {
    for (i = 0; i < V; i++) {
      for (j = 0; j < V; j++) {
        if (!graph[i][k] || !graph[k][j]) continue;
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          if (prevv[i][j] != -1) {
            if (cnt[prevv[i][j]][j] == 1) mark[prevv[i][j]][j] = 0;
            cnt[prevv[i][j]][j]--;
          }
          mark[k][j] = 1;
          cnt[k][j]++;
          prevv[i][j] = k;
        }
      }
    }
  }
}
set<pair<int, int> > s;
int main(void) {
  int n, m;
  cin >> n >> m;
  memset(graph, 0, sizeof(graph));
  memset(cnt, 0, sizeof(cnt));
  memset(mark, 0, sizeof(mark));
  memset(prevv, -1, sizeof(prevv));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  V = n;
  floydWarshall();
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (mark[i][j]) cnt++;
    }
  }
  cout << (m - cnt);
  return 0;
}
